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. Application-Wide Stylesheet not applied on widget
Forum Updated to NodeBB v4.3 + New Features

Application-Wide Stylesheet not applied on widget

Scheduled Pinned Locked Moved Solved General and Desktop
13 Posts 4 Posters 5.3k Views 4 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.
  • Chris KawaC Offline
    Chris KawaC Offline
    Chris Kawa
    Lifetime Qt Champion
    wrote on last edited by
    #4

    Sounds like a problem with missing/incorrect implementation of the paintEvent. Can you show it?

    Btw. Calling show() from a constructor is bad manners. What if someone just wants an instance of your class without showing it (e.g. to put it in a stack or a tab)? Don't decide for them.

    jensen82J 2 Replies Last reply
    0
    • jensen82J jensen82

      Hi!

      No, the MACRO is there. If i've had forgotten the MACRO the setStyleSheet in the constructor wouldn't work.

      Thank you!

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #5

      @jensen82 said in Application-Wide Stylesheet not applied on widget:

      No, the MACRO is there. If i've had forgotten the MACRO the setStyleSheet in the constructor wouldn't work.

      no, since you're not using a class name in this style declaration...

      Show the definition in the QSS file before the one that isn't working. Maybe you've a parsing error in it.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      jensen82J 1 Reply Last reply
      0
      • Chris KawaC Chris Kawa

        Sounds like a problem with missing/incorrect implementation of the paintEvent. Can you show it?

        Btw. Calling show() from a constructor is bad manners. What if someone just wants an instance of your class without showing it (e.g. to put it in a stack or a tab)? Don't decide for them.

        jensen82J Offline
        jensen82J Offline
        jensen82
        wrote on last edited by
        #6

        @Chris-Kawa Yes, i know. The show was for testing purposes.

        1 Reply Last reply
        0
        • raven-worxR raven-worx

          @jensen82 said in Application-Wide Stylesheet not applied on widget:

          No, the MACRO is there. If i've had forgotten the MACRO the setStyleSheet in the constructor wouldn't work.

          no, since you're not using a class name in this style declaration...

          Show the definition in the QSS file before the one that isn't working. Maybe you've a parsing error in it.

          jensen82J Offline
          jensen82J Offline
          jensen82
          wrote on last edited by
          #7

          @raven-worx The parsing-test was successful. No parsing error present.

          Here's the Headerfile for TopNavigationLine:

          class TopNavigationLine : public AUTBaseWidget {
              Q_OBJECT
              public:
              explicit TopNavigationLine(QWidget* parent = 0);
              ~TopNavigationLine();
          
              private:
              Ui::TopNavigationLine* ui;
          };
          
          raven-worxR 2 Replies Last reply
          0
          • jensen82J jensen82

            @raven-worx The parsing-test was successful. No parsing error present.

            Here's the Headerfile for TopNavigationLine:

            class TopNavigationLine : public AUTBaseWidget {
                Q_OBJECT
                public:
                explicit TopNavigationLine(QWidget* parent = 0);
                ~TopNavigationLine();
            
                private:
                Ui::TopNavigationLine* ui;
            };
            
            raven-worxR Offline
            raven-worxR Offline
            raven-worx
            Moderators
            wrote on last edited by
            #8

            @jensen82
            you should please provide what you were asked for in order to receive proper help.

            --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
            If you have a question please use the forum so others can benefit from the solution in the future

            1 Reply Last reply
            0
            • Chris KawaC Chris Kawa

              Sounds like a problem with missing/incorrect implementation of the paintEvent. Can you show it?

              Btw. Calling show() from a constructor is bad manners. What if someone just wants an instance of your class without showing it (e.g. to put it in a stack or a tab)? Don't decide for them.

              jensen82J Offline
              jensen82J Offline
              jensen82
              wrote on last edited by
              #9

              @Chris-Kawa So here's the paintEvent

              void AUTBaseWidget::paintEvent(QPaintEvent* event)
              {
                  Q_UNUSED(event);
                  QStyleOption opt;
                  opt.init(this);
                  QPainter p(this);
                  style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
              }
              
              

              This code works for other derived widgets

              1 Reply Last reply
              0
              • jensen82J jensen82

                @raven-worx The parsing-test was successful. No parsing error present.

                Here's the Headerfile for TopNavigationLine:

                class TopNavigationLine : public AUTBaseWidget {
                    Q_OBJECT
                    public:
                    explicit TopNavigationLine(QWidget* parent = 0);
                    ~TopNavigationLine();
                
                    private:
                    Ui::TopNavigationLine* ui;
                };
                
                raven-worxR Offline
                raven-worxR Offline
                raven-worx
                Moderators
                wrote on last edited by
                #10

                @jensen82 said in Application-Wide Stylesheet not applied on widget:

                The parsing-test was successful. No parsing error present.

                i am wondering how you exactly checked for an error?
                A normal CSS parser isn't appropriate here btw.

                --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                If you have a question please use the forum so others can benefit from the solution in the future

                1 Reply Last reply
                0
                • ? Offline
                  ? Offline
                  A Former User
                  wrote on last edited by A Former User
                  #11

                  Isn't there a superfluous semi-colon in setStyleSheet("background-color: rgb(77 , 77, 77);"); ?

                  jensen82J 1 Reply Last reply
                  0
                  • ? A Former User

                    Isn't there a superfluous semi-colon in setStyleSheet("background-color: rgb(77 , 77, 77);"); ?

                    jensen82J Offline
                    jensen82J Offline
                    jensen82
                    wrote on last edited by
                    #12

                    @Ian-Bray No. I think i got the error. I saved the file in UTF-8 and now it works. Strange...

                    1 Reply Last reply
                    0
                    • jensen82J Offline
                      jensen82J Offline
                      jensen82
                      wrote on last edited by
                      #13

                      Thank you all for your help!

                      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