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. I just applied setStyleSheet to one label in mainwindow... it effected all other labels in other files also...which i don want
Forum Updated to NodeBB v4.3 + New Features

I just applied setStyleSheet to one label in mainwindow... it effected all other labels in other files also...which i don want

Scheduled Pinned Locked Moved General and Desktop
11 Posts 3 Posters 1.8k 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.
  • P Offline
    P Offline
    Phani Madhavi
    wrote on last edited by
    #1

    can any one help me

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      Perhaps you have mistakenly applied it to the MainWindow itself? It woould then propagate the style to all it's children.

      (Z(:^

      1 Reply Last reply
      0
      • P Offline
        P Offline
        Phani Madhavi
        wrote on last edited by
        #3

        no actually i created a QLabel(named Activethumb) and i applied setStylesheet in code .i am creating new QLables when ever i want by "=new Activethumb" like that...but the style was effecting to others also

        1 Reply Last reply
        0
        • P Offline
          P Offline
          Phani Madhavi
          wrote on last edited by
          #4

          i am creatind new Activethumbs from mainwindow

          1 Reply Last reply
          0
          • sierdzioS Offline
            sierdzioS Offline
            sierdzio
            Moderators
            wrote on last edited by
            #5

            I'm not sure I fully understand you, but it looks like you are doing it correctly.

            (Z(:^

            1 Reply Last reply
            0
            • P Offline
              P Offline
              Phani Madhavi
              wrote on last edited by
              #6

              then y it is effecting other ui's also...is there any option?

              1 Reply Last reply
              0
              • sierdzioS Offline
                sierdzioS Offline
                sierdzio
                Moderators
                wrote on last edited by
                #7

                There are many ways to apply a stylesheet. You can apply it to QApplication (it will be used by all widgets), or to QWidget (it will be used by that widget, and all it's children). You can also specify class selectors inside the stylesheet, so that the style is applied only to a certain class name, or even certain object name. I don't know exactly how you are doing this, so it's difficult to tell you anything more helpful.

                (Z(:^

                1 Reply Last reply
                0
                • P Offline
                  P Offline
                  Phani Madhavi
                  wrote on last edited by
                  #8

                  i am using the second one u mentioned.....it is effecting to children... can u pls tell me third one in detail

                  1 Reply Last reply
                  0
                  • sierdzioS Offline
                    sierdzioS Offline
                    sierdzio
                    Moderators
                    wrote on last edited by
                    #9

                    Please take a look at "the documentation":http://qt-project.org/doc/qt-5/stylesheet-syntax.html.

                    Also, "this":http://qt-project.org/doc/qt-5/stylesheet-reference.html, and "this":http://qt-project.org/doc/qt-5/stylesheet-customizing.html.

                    (Z(:^

                    1 Reply Last reply
                    0
                    • R Offline
                      R Offline
                      ray4qt
                      wrote on last edited by
                      #10

                      Have you tried using the object name, one of the options suggested by sierdzio?

                      That would restrict the style to that particular label, I believe.

                      @QLabel#Activethumb@

                      Have a look here http://qt-project.org/doc/qt-5/stylesheet-syntax.html

                      The part 'Selector Types' is what you are after.

                      As he says, it is hard to help without seeing your code.

                      1 Reply Last reply
                      0
                      • P Offline
                        P Offline
                        Phani Madhavi
                        wrote on last edited by
                        #11

                        I wrote this code in Activethumb.cpp(which is a QLabel)
                        @
                        this->setStyleSheet("border: 4px solid rgb(189,189,189)");
                        @

                        And this lable activethumb is created with resp to the number of items(images)to display
                        @
                        productThumbs[index] =
                        new ActiveThumb(this->ui>scrollAreaWidgetContents_Puzzle,
                        QRect(x, y, thumbWidth, thumbHeight),
                        finalPuzzle.at(index).toObject(),"P");
                        @
                        this code i wrote in mainwindow.cpp

                        [code tags added by sierdzio]

                        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