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. QSS Styling a QToolBox's Page.
Forum Updated to NodeBB v4.3 + New Features

QSS Styling a QToolBox's Page.

Scheduled Pinned Locked Moved General and Desktop
11 Posts 4 Posters 13.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.
  • G Offline
    G Offline
    goetz
    wrote on last edited by
    #2

    Good point. Would you mind creating a wiki page for it (in the "How To":http://developer.qt.nokia.com/wiki/Category:HowTo section)

    http://www.catb.org/~esr/faqs/smart-questions.html

    1 Reply Last reply
    0
    • I Offline
      I Offline
      ivan.todorovich
      wrote on last edited by
      #3

      Ok.. i've created the wiki page. http://developer.qt.nokia.com/wiki/Style_a_QToolBoxs_Page_with_QSS

      o_o Sorry for my rusted english.

      1 Reply Last reply
      0
      • D Offline
        D Offline
        dangelog
        wrote on last edited by
        #4

        Why are you using the child selector and not the descendant selector + an id/property selector (to avoid blindly matching every QToolBox subwidget)?

        I.e.
        @
        QToolBox QWidget#myId { ... }
        @

        or

        @
        QToolBox QWidget[myProperty="true"] {...}
        @

        Software Engineer
        KDAB (UK) Ltd., a KDAB Group company

        1 Reply Last reply
        0
        • I Offline
          I Offline
          ivan.todorovich
          wrote on last edited by
          #5

          i am not matching every QToolBox subwidget, just the page widgets..
          because i may not necessary know the ids or the widgets nor want to select by a specific property.

          @QToolBox > QScrollArea > QWidget > QWidget@
          is very different to
          @QToolBox QScrollArea QWidget QWidget@
          That last one would match every QToolBox sub-widget.

          I think you are mistaken--

          o_o Sorry for my rusted english.

          1 Reply Last reply
          0
          • D Offline
            D Offline
            dangelog
            wrote on last edited by
            #6

            That's why I said
            [quote]
            an id/property selector (to avoid blindly matching every QToolBox subwidget)?
            [/quote]

            I.e.

            @
            QWidget *w = new QWidget;
            w->setObjectName("MyWidget");
            toolbox->addItem(w, "foo");
            @

            styled with

            @
            QToolBox QWidget#MyWidget { ... }
            @

            Software Engineer
            KDAB (UK) Ltd., a KDAB Group company

            1 Reply Last reply
            0
            • I Offline
              I Offline
              ivan.todorovich
              wrote on last edited by
              #7

              What if you created the pages with QtDesigner?
              And you want to target every QToolBox page. IE: Give they a white background-color.

              o_o Sorry for my rusted english.

              1 Reply Last reply
              0
              • D Offline
                D Offline
                dangelog
                wrote on last edited by
                #8

                [quote]What if you created the pages with QtDesigner?
                And you want to target every QToolBox page. IE: Give they a white background-color.[/quote]

                You simply change each page's object name, or set a dynamic property on them with a value of yours. What I am pointing out is NOT that your solution doesn't work, but that requires how QToolBox is internally implemented. My solution instead "just works".

                Check it out: http://qt.pastebin.com/4X2ZfHWz

                Software Engineer
                KDAB (UK) Ltd., a KDAB Group company

                1 Reply Last reply
                0
                • T Offline
                  T Offline
                  Tedisito
                  wrote on last edited by
                  #9

                  Hey,
                  I tried the solution of peppe, it works but only in the Qt designer, then when you run the application the background color of the Qtoolbox page does not appear like in Qt Designer but with the grey color.
                  While in contrast, the solution of ivan works in both cases.

                  I am trying to make the page transparent but it seems that it does not work. Do you know why? And how to make the QToolBox page transparent?

                  Thank you

                  1 Reply Last reply
                  0
                  • D Offline
                    D Offline
                    dangelog
                    wrote on last edited by
                    #10

                    @
                    #include <QtGui>

                    int main(int argc, char **argv)
                    {
                    QApplication app(argc, argv);

                    QToolBox toolBox;
                    
                    for (int i = 0; i < 5; ++i) {
                        toolBox.addItem(new QWidget, QString("Tab #%1").arg(i));
                    }
                    
                    toolBox.widget(0)->setProperty("myProperty", true);
                    toolBox.widget(1)->setProperty("myProperty", true);
                    
                    toolBox.show();
                    
                    app.setStyleSheet("QToolBox QWidget[myProperty=\"true\"] { background-color: white; }");
                    
                    return app.exec();
                    

                    }
                    @

                    This is still working for me (notice that object names / dynamic properties must be set before the stylesheet, due to how Qt style sheets work). What do you mean with "make the page transparent"? Like, a "hole" inside the QToolBox?

                    Software Engineer
                    KDAB (UK) Ltd., a KDAB Group company

                    1 Reply Last reply
                    0
                    • T Offline
                      T Offline
                      Tedisito
                      wrote on last edited by
                      #11

                      Thanks for the notice, that was why it didn't work.
                      By make the page transparent, I mean have a hole inside the QToolBox. And actually not a "hole" like 100% transparent but I would to set the transparency.

                      For example, if you set the stylesheet with:
                      @QToolBox QWidget[myProperty="true"] { background-color: rgba(0, 255, 0,20); }@

                      You'll see some green and the transparency are here too BUT still with the gray in background. Like if there is another widget to set!

                      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