QTabWidget怎样设置tab标签的间隙,使得tab标签不粘在一起?
QTabWidget怎样设置tab标签的间隙,使得tab标签不粘在一起?
[解决办法]
int main(int argc, char**argv)
{
QApplication app(argc,argv);
QTabWidget tabWidget;
QWidget widget1, widget2, widget3;
tabWidget.addTab(&widget1, "test");
tabWidget.addTab(&widget2, "test1");
tabWidget.addTab(&widget3, "test2");
tabWidget.setStyleSheet("QTabBar::tab:first:selected {\
margin-left: 30; margin-right: 0;\
}\
QTabBar::tab:first:!selected {\
margin-left: 30; margin-right: 0;\
}\
QTabBar::tab:first:hover:!selected {\
margin-left: 30; margin-right: 0;\
}\
QTabBar::tab:middle:selected {\
margin-top: 0; margin-left: 30; margin-right: 8;\
}\
QTabBar::tab:middle:!selected {\
margin-top: 0; margin-left: 30; margin-right: 8;\
}\
QTabBar::tab:middle:hover:!selected {\
margin-top: 0; margin-left: 30; margin-right: 8;\
}\
QTabBar::tab:last:selected {\
margin-top: 0px; margin-left: 100; margin-right: 0;\
}\
QTabBar::tab:last:!selected {\
margin-top: 0; margin-left: 100; margin-right: 0;\
}\
QTabBar::tab:last:hover:!selected {\
margin-top: 0; margin-left: 100; margin-right: 0;\
}\
QTabBar::tab:only-one {\
margin: 0;\
}");
tabWidget.show();
return app.exec();
}
这是我做的一个例子,你自己按你的要求调整宽度