1 | #include <QtGui/QtGui>
|
---|
2 | #include <QtGui/qmacnativewidget_mac.h>
|
---|
3 | #ifdef QT_MAC_USE_COCOA
|
---|
4 | #import <Cocoa/Cocoa.h>
|
---|
5 | #else
|
---|
6 | #include <Carbon/Carbon.h>
|
---|
7 | #endif
|
---|
8 |
|
---|
9 | int main(int argc, char **argv)
|
---|
10 | {
|
---|
11 | QApplication app(argc, argv);
|
---|
12 | #ifdef QT_MAC_USE_COCOA
|
---|
13 | //![0]
|
---|
14 | NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
---|
15 | NSWindow *window = [[NSWindow alloc] initWithContentRect:NSMakeRect(200, app.desktop()->height() - 200, 239, 200)
|
---|
16 | styleMask:NSTitledWindowMask | NSClosableWindowMask
|
---|
17 | | NSMiniaturizableWindowMask | NSResizableWindowMask
|
---|
18 | backing:NSBackingStoreBuffered defer:NO];
|
---|
19 |
|
---|
20 | QMacNativeWidget *nativeWidget = new QMacNativeWidget();
|
---|
21 | nativeWidget->move(0, 0);
|
---|
22 | nativeWidget->setPalette(QPalette(Qt::red));
|
---|
23 | nativeWidget->setAutoFillBackground(true);
|
---|
24 | QVBoxLayout *layout = new QVBoxLayout();
|
---|
25 | QPushButton *pushButton = new QPushButton("An Embedded Qt Button!", nativeWidget);
|
---|
26 | pushButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); // Don't use the layout rect calculated from QMacStyle.
|
---|
27 | layout->addWidget(pushButton);
|
---|
|
---|