Results 1 to 2 of 2

Thread: StyleSheets/QTabBar -- max-width property not respected.

  1. #1
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    258
    Thanks
    22
    Thanked 19 Times in 16 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default StyleSheets/QTabBar -- max-width property not respected.

    I want to restrict the min- and max-width of a Tab in a QTabBar to a certain range. The min-width property is being respected whereas the max-width property is being ignored. The docs list a bunch of widgets that support these properties and the list is identical for both. QTabBar is not explicitly listed but elsewhere in the docs min-width is being used to set the min-width of a QTabBar. Thus one would assume that QTabBar is able to support both properties. I want the text to be elided if the size exceeds the max-width value. I can use elidedText() but using stylesheets would be way more convenient.
    Any ideas?

    Thanx in advance

    Qt Code:
    1. #include <QApplication>
    2. #include <QtGui>
    3.  
    4. void setStyleSheet();
    5. int main(int argc, char* argv[])
    6. {
    7. QApplication app(argc, argv);
    8. setStyleSheet();
    9. mw.showMaximized();
    10. QTabWidget* tabWidget = new QTabWidget;
    11. QString s = "a";
    12. for (int i = 0; i < 6; i++) tabWidget->addTab(new QWidget(), s += s);
    13. mw.setCentralWidget(tabWidget);
    14. mw.show();
    15. return app.exec();
    16. }
    17.  
    18. void setStyleSheet()
    19. {
    20. QString style;
    21. QTextStream stream(&style);
    22.  
    23. stream << "QTabWidget::pane {"
    24. << "border-top: 2px solid darkgray;"
    25. << "}"
    26. << "QTabBar::tab {"
    27. << "margin-top:3px;"
    28. << "background-color: white;"
    29. << "border: 1px solid darkgray;"
    30. << "margin-left: 2px;"
    31. << "border-top-right-radius: 10%;"
    32. << "border-top-left-radius: 10%;"
    33. << "padding: 5px;"
    34. << "min-width:100px;"
    35. << "max-width:130px;"
    36. << "}";
    37.  
    38. qApp->setStyleSheet(style);
    39. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: StyleSheets/QTabBar -- max-width property not respected.

    If QTabBar isn't listed then I suspect there is a reason for that.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.