#include <QtGui>
#include <QtWidgets>
#include <QMainWindow>
#import <Cocoa/Cocoa.h>

class SearchWidget : public QWidget
{
public:
    SearchWidget(QWidget *parent = 0);
    QSize sizeHint() const { return QSize(200, 40); }
};

class SearchWrapper : public QWidget
{
public:
	SearchWrapper(QWidget* parent = 0)
		:
		QWidget(parent)
	{
			s = new SearchWidget(this);
	}

    QSize sizeHint() const { return s->sizeHint(); }
    QWidget* s;
};

SearchWidget::SearchWidget(QWidget *parent)
	:
	QWidget(parent)
{
    NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];

	NSSearchField     *search = [[NSSearchField     alloc] init];
	[[search cell] setPlaceholderString:@"Cocoa Native"];

	setAttribute(Qt::WA_NativeWindow);
	create(WId(search), false, true);

    [search release];
    [pool   release];

}

QWidget* CocoaWidget()
{
	return new SearchWrapper;
}

int main(int argc, char* argv[])
{
	QApplication app(argc, argv);
	
	QMainWindow* window = new QMainWindow;
	window->setWindowTitle(QLatin1String("Main Window"));
	window->resize(200,200);
	window->move(100,100);
	window->show();
	
	window->setCentralWidget(new SearchWrapper);
	
	return app.exec();
}

