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. QMainWindow Problem
QtWS25 Last Chance

QMainWindow Problem

Scheduled Pinned Locked Moved General and Desktop
7 Posts 4 Posters 3.6k Views
  • 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.
  • K Offline
    K Offline
    Ketan Shah
    wrote on last edited by
    #1

    In my application there are 3 windows: One Main Window, and two child windows.
    I am changing my main windows background color to white using setstylesheet..
    so this is also applying the same settings to my child windows, which I dont want..
    In one of my child windows there is a listview with scrollbar, they are also becoming white.
    so my question is how can I change my two child windows background settings to their default settings.

    Thanx in advance..

    1 Reply Last reply
    0
    • G Offline
      G Offline
      giesbert
      wrote on last edited by
      #2

      Please post your style sheet, how you set it and how you create your widgets. Somewhere in that, I assume, area is the bug.

      Nokia Certified Qt Specialist.
      Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

      1 Reply Last reply
      0
      • K Offline
        K Offline
        Ketan Shah
        wrote on last edited by
        #3

        @myWindow->setStyleSheet(QString::fromUtf8("background-color: rgb(254, 255, 247);"));@

        1 Reply Last reply
        0
        • K Offline
          K Offline
          Ketan Shah
          wrote on last edited by
          #4

          @extension *e = new extension(this);
          e->setWindowModality(Qt::WindowModal);
          e->show();

          a = new ampstart(this);
          a->setWindowModality(Qt::WindowModal);
          a->show();
          @

          above is the way how I created my stylesheet, and the two child windows..

          1 Reply Last reply
          0
          • Z Offline
            Z Offline
            ZapB
            wrote on last edited by
            #5

            You need to use a more specific selector to ensure that only your QMainWindow selects that particular syle.

            Something like this stylesheet snippet should do it:

            @
            QMainWindow {
            background-color: rgb(254, 255, 247);
            }
            @

            You can set this directly on yoru mainwindow via the ui file. Just right-click on the main window in design mode of creator and select "Change Stylesheet..." and past the above in and hit Apply.

            Nokia Certified Qt Specialist
            Interested in hearing about Qt related work

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

              Yes, I agree with ZapB but I have one comment about the two child windows.
              It is not necessary to call show() explicitly for each child as they will be show when the parent window is visible.

              1 Reply Last reply
              0
              • G Offline
                G Offline
                giesbert
                wrote on last edited by
                #7

                [quote author="ZapB" date="1310040148"]You need to use a more specific selector to ensure that only your QMainWindow selects that particular syle.

                Something like this stylesheet snippet should do it:

                @
                QMainWindow {
                background-color: rgb(254, 255, 247);
                }
                @

                You can set this directly on yoru mainwindow via the ui file. Just right-click on the main window in design mode of creator and select "Change Stylesheet..." and past the above in and hit Apply.[/quote]

                The reason why this is needed is that style sheets are also derived / forwarded to shildren. And you set the properties in a generic way.

                Nokia Certified Qt Specialist.
                Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                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