#include <QApplication>#include <QTabWidget>#include <QPushButton>#include <QDockWidget>class TestPushButton:public QPushButton{public: TestPushButton(QWidget*parent=0):QPushButton(parent){}protected: virtual bool event(QEvent *e){ switch((int)e->type()){ case QEvent::MouseButtonRelease: setMinimumSize(width(),height()); } return QPushButton::event(e); }};int main(int argc,char**argv){ QApplication app(argc,argv); QDockWidget dw; QTabWidget *ptw=new QTabWidget; ptw->setTabPosition(QTabWidget::East); TestPushButton *ppb=new TestPushButton; ptw->addTab(ppb,""); dw.setWidget(ptw); dw.show(); return app.exec();}
int main(int argc,char**argv){ QApplication app(argc,argv); QDockWidget dw; QWidget *pwgt=new QWidget; QGridLayout *pgl=new QGridLayout; pgl->setMargin(0); QTabWidget *ptw=new QTabWidget; ptw->setTabPosition(QTabWidget::East); ptw->addTab(new QWidget,""); pgl->addWidget(ptw,0,0,3,3); QStackedWidget *psw=new QStackedWidget; TestPushButton *ppb=new TestPushButton; psw->addWidget(ppb); pgl->addWidget(psw,1,1,1,1); pgl->addItem(new QSpacerItem(QApplication::style()->pixelMetric(QStyle::PM_TabBarTabHSpace)-QApplication::style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing),0),1,2); pwgt->setLayout(pgl); dw.setWidget(pwgt); dw.show(); return app.exec();}