Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED]QTabBar stylesheet
Forum Updated to NodeBB v4.3 + New Features

[SOLVED]QTabBar stylesheet

Scheduled Pinned Locked Moved General and Desktop
11 Posts 2 Posters 7.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mbnoimi
    wrote on last edited by
    #1

    How can I specify id for QTabBar in stylesheet?
    Example:
    @
    QTabWidget#tabWidget_sidebar {
    background-color: rgba(0, 0, 255, 255);
    }

    /***** ERROR *****/
    QTabBar#tabWidget_sidebar::tab {
    background-color: rgb(255, 0, 0);
    padding:5px;
    border: 10px;
    text-align: center;
    height:64px;
    width:64px;
    }@

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Are you searching for "this":http://qt-project.org/doc/qt-4.8/stylesheet-examples.html#customizing-qtabwidget-and-qtabbar ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mbnoimi
        wrote on last edited by
        #3

        Sure it didn't fit my needs.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Just to be sure, did you set your widget name with setObjectName ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mbnoimi
            wrote on last edited by
            #5

            [quote]
            Just to be sure, did you set your widget name with setObjectName ?
            [/quote]
            Nope, I set the objectName through Qt Designer.

            Note: QTabWidget#tabWidget_sidebar works fine while QTabBar#tabWidget_sidebar::tab doesn't

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Because the name is set to the QTabWidget not the QTabBar from the QTabWidget

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • M Offline
                M Offline
                mbnoimi
                wrote on last edited by
                #7

                bq. Because the name is set to the QTabWidget not the QTabBar from the QTabWidget

                You mean I've to set the name from the code not from the GUI designer?

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  I don't remember if designer allows to name sub-control widgets, you would have to try that.

                  Or you could use the tab-bar subcontrol in your style sheet

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • M Offline
                    M Offline
                    mbnoimi
                    wrote on last edited by
                    #9

                    [quote]I don’t remember if designer allows to name sub-control widgets, you would have to try that.[/quote]
                    Unfortunately Qt Designer doens't allow to name sub-controls (I'll file a feature request) so I fixed this issue by calling this in the constructor:
                    [code]ui->tabWidget_sidebar->tabBar()->setObjectName("tabBar");[/code]

                    And used the following stylesheet:
                    [code]QTabBar#tabBar::tab {
                    background-color: rgb(0, 0, 0, 0);
                    padding: 2px;
                    border: 2px;
                    text-align: center;
                    height: 64px;
                    width: 64px;
                    }

                    QTabBar#tabBar::tab:selected {
                    background-color: rgba(255, 255, 255, 100);
                    }

                    QTabBar#tabBar::tab:hover {
                    background-color: rgba(255, 255, 255, 150);
                    }[/code]

                    Thank you SGaist

                    1 Reply Last reply
                    0
                    • M Offline
                      M Offline
                      mbnoimi
                      wrote on last edited by
                      #10

                      I post a suggestion in:
                      https://bugreports.qt-project.org/browse/QTBUG-33159

                      1 Reply Last reply
                      0
                      • SGaistS Offline
                        SGaistS Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on last edited by
                        #11

                        You're welcome !

                        Then why not use the tab-bar sub control keyword in the stylesheet ?

                        Interested in AI ? www.idiap.ch
                        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                        1 Reply Last reply
                        0

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved