2013-07-24 51 views
2

我在想如何調整QMainWindow窗口裝飾的大小(特別是高度)。我需要類似於QtDesigner,Xcode和Skype的行爲。我嘗試添加在QToolBar用下面的代碼:如何調整QMainWindow上的窗口裝飾大小?

QMainWindow *mainWindow = new QMainWindow(); 
QToolBar *bar = new QToolBar(); 
bar->setFixedHeight(100); 
bar->setFloatable(false); 
bar->setMovable(false); 
mainWindow->addToolBar(bar); 

mainWindow->show(); 

比起它就是我想要的還有很長的路要走 - : On the left you can see what I want and on the right you can see what I currently have 在左邊,你可以看到我想要什麼,右邊就可以看到我目前有什麼。

這在Qt中可能嗎?如果是的話,這個效果如何實現?

回答

3

解決方案很簡單。所有我需要做的就是調用:

mainWindow->setUnifiedTitleAndToolBarOnMac(true);

問題解決了!


編輯,2013年8月19日:

看來,作爲QT5的,你需要拉這個git repository和構建庫 - 然後將其鏈接到您的項目。爲了設置統一標題和工具欄,請參閱存儲庫中提供的示例。