C++ (Qt) QFrame *frame = new QFrame( this); QApplication::setStyle( new QWindowsStyle()); QMenuBar *menuBar = new QMenuBar( this); menuBar->setMinimumHeight( 200); QMenu *FirstMenu = new QMenu( menuBar); FirstMenu->setMinimumHeight( 200); FirstMenu->setTitle( tr( "First")); FirstMenu->addMenu( "menu"); menuBar->addMenu( FirstMenu); QMenu *SecondMenu = new QMenu( menuBar); SecondMenu->setTitle( tr( "Second")); menuBar->addMenu( SecondMenu); QPalette pal( palette()); pal.setBrush( backgroundRole() , QBrush( QColor(0, 0, 255, 255)) ); pal.setBrush( foregroundRole() , QBrush( QColor(255, 255, 255, 255)) ); setPalette( pal); setAutoFillBackground( true); frame->setFrameShape( QFrame::Box); frame->setGeometry( menuBar->geometry());
C++ (Qt)class MyProxyStyle : public QProxyStyle{public: QSize sizeFromContents(ContentsType ct, const QStyleOption *opt, const QSize &csz, const QWidget *widget) const { QSize sz(csz); switch(ct) { case CT_MenuBarItem: { QSize newsz = QProxyStyle::sizeFromContents(ct, opt, sz, widget); newsz.rheight() += 30; newsz.rwidth() += 10; sz = newsz; break; } default: sz = QProxyStyle::sizeFromContents(ct, opt, csz, widget); break; } return sz; }}; int main(int argc, char *argv[]){ QApplication a(argc, argv); MyProxyStyle* mps = new MyProxyStyle; a.setStyle(mps); MainWindow w; w.show(); return a.exec();}