当前位置: 代码迷 >> QT开发 >> QTabWidget怎样设置tab标签的空当,使得tab标签不粘在一起
  详细解决方案

QTabWidget怎样设置tab标签的空当,使得tab标签不粘在一起

热度:81   发布时间:2016-04-25 03:34:57.0
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();