Reputation: 2317
Mac OS X has a standard colour picking button (Cocoa class: NSColorWell).
Is there any way to use these for the Mac version of my product in Qt?
I am using Qt 4.8.1 on Mac OS X 10.6.
Upvotes: 1
Views: 296
Reputation: 17956
QMacCocoaViewContainer can handle scenarios like this. The basic usage is:
class MacControl : public QMacCocoaViewContainer {
Q_OBJECT
public:
explicit MacControl(QWidget *parent = NULL)
: QMacCocoaViewContainer(NULL, parent) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSColorWell *colors = [[NSColorWell alloc] init];
// set properties on color well
setCocoaView(color);
[colors release];
[pool release];
}
Actually, you probably won't be able to put it all in one file if you are compiling for multiple platforms. You would have a header file that declares a method that can be called from any platform, a cpp
file that implements the method by calling the normal Qt color dialog for non-Mac, and an mm
file that creates the Mac-specific widget and displays it.
Upvotes: 2