Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    A stylesheet for each dialog

    General and Desktop
    2
    6
    1254
    Loading More Posts
    • 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.
    • mrdebug
      mrdebug last edited by

      I use this function
      this->setStyleSheet
      to set the stylesheet. Is possible to have a different stylesheet for each dialog?
      Can you post an example?

      Need programmers to hire?
      www.labcsp.com
      www.denisgottardello.it
      GMT+1
      Skype: mrdebug

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi,

        Yes, it's possible. However you don't tell it you want to change the style sheet for different dialogs classes or different instance of the same dialog class

        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 Reply Quote 0
        • mrdebug
          mrdebug last edited by

          Can you give me an example?
          In the main Form I call setStyleSheet() and the QButtons have the custom stylesheet.
          @#QFMainForm QPushButton:pressed {
          background: qradialgradient(cx: 0.4, cy: -0.1, fx: 0.4, fy: -0.1, radius: 1.35, stop: 0 #fff, stop: 1 #ddd);
          }@
          This stylesheet appears in the children dialogs.
          How can I have another QButton stylesheet for the children dialogs?

          Need programmers to hire?
          www.labcsp.com
          www.denisgottardello.it
          GMT+1
          Skype: mrdebug

          1 Reply Last reply Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by

            Set another stylesheet on the dialog

            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 Reply Quote 0
            • mrdebug
              mrdebug last edited by

              It isn't a nice solution. Is necessary to replace all attributes.
              For example if in the main window I have
              @#QFMainForm QPushButton {
              color: white;
              font-size: 28px;
              }@

              and in the child dialog I have
              @#QFMainForm QPushButton {
              color: white;
              }@

              without attribute "font-size: 28px;", I will have the font size= 28 in the child dialog. To have the normal size I have to replace the font-size attribute too.
              Is there another way?

              Need programmers to hire?
              www.labcsp.com
              www.denisgottardello.it
              GMT+1
              Skype: mrdebug

              1 Reply Last reply Reply Quote 0
              • SGaist
                SGaist Lifetime Qt Champion last edited by

                Then make your stylesheet more specialized, by using e.g. object names

                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 Reply Quote 0
                • First post
                  Last post