Quote Originally Posted by wysota View Post
The solution you currently have will fail on Mac and some of the other desktop environments in their default or personalized configurations. Mac draws most of things with rounded corners so at best you will likely hit a transparent area. There are also widget styles that don't draw a border at all or draw a gradient border or do one of the numerous other things that will make your approach fail. Using stylesheets will also make your approach fail on pretty much every possible configuration. As I understand it, you have tested your solution on Windows 7. Did you consider other systems too? You should either assume your code to be unportable and focus on a particular plartform configuration or you should accept the fact that your solution is not a solution at all (not even a "solution") and just do the drawing using QStyle API and QPalette. Especially considering the fact that a border is really a trivial issue. Think about drawing highlights or opaque areas the theme draws as a gradient. You can't possibly emulate that without reverting to the API that originally drew those elements. The final result can be even worse than if you had used a standard approach which works on most systems (which is all excluding Vista+ and MacOSX) out of the box.
Ok, what I am after is drawing a border (or part of a border, e.g. only the top part of a border) around a widget using a colour which is consistent with those used by other widgets.

I have indeed tested my current approach on Windows 7, but also on Mac OS X (Lion) and Ubuntu (11.10), and it all works as expected. Now, I agree that there is no guarantee whatsoever that it would work in some other random settings, and I have never claimed that it would.

Regarding QStyle (and QStylePainter), I have looked into it and it would work fine for a full border (I have tried it), but what about the case where I only need part of a border?...