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. Why sometimes the style of a button changes
Forum Updated to NodeBB v4.3 + New Features

Why sometimes the style of a button changes

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 3 Posters 530 Views 2 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.
  • J Offline
    J Offline
    John Van
    wrote on last edited by John Van
    #1

    The upper part of this picture is the style I set, and the third button is the hover state. But sometimes after the program runs for a period of time, When I hovered the mouse over the button, it changed to look like the bottom half of the image, and their functions are normal at this time. Because the styles of these buttons will not change during program operation, I am puzzled why this is the case?
    2023-11-13_134739.png

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      How are you rendering this button ?
      On which platform ?
      With version of Qt ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      J 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        How are you rendering this button ?
        On which platform ?
        With version of Qt ?

        J Offline
        J Offline
        John Van
        wrote on last edited by John Van
        #3

        @SGaist

            ui->btn_min->setIcon(icon);
            ui->btn_min->setIconSize(QSize(25, 25));
        ui->btn_min->setStyleSheet("QPushButton#btn_min,#btn_max { background-color: #303030; } QPushButton#btn_min:hover { background-color: #454545; }");
        

        vs2019+qt vs tools
        qt 5.14.2

        This situation only occurs occasionally, so I'm sorry I couldn't find some pattern to provide more information.

        Thanks.

        SGaistS C 2 Replies Last reply
        0
        • J John Van

          @SGaist

              ui->btn_min->setIcon(icon);
              ui->btn_min->setIconSize(QSize(25, 25));
          ui->btn_min->setStyleSheet("QPushButton#btn_min,#btn_max { background-color: #303030; } QPushButton#btn_min:hover { background-color: #454545; }");
          

          vs2019+qt vs tools
          qt 5.14.2

          This situation only occurs occasionally, so I'm sorry I couldn't find some pattern to provide more information.

          Thanks.

          SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          You should test this with a more recent version of Qt.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          J 1 Reply Last reply
          0
          • SGaistS SGaist

            You should test this with a more recent version of Qt.

            J Offline
            J Offline
            John Van
            wrote on last edited by
            #5

            @SGaist
            It still happened in Qt 5.15.11. Can you give me some advice?

            Thanks

            1 Reply Last reply
            0
            • J John Van

              @SGaist

                  ui->btn_min->setIcon(icon);
                  ui->btn_min->setIconSize(QSize(25, 25));
              ui->btn_min->setStyleSheet("QPushButton#btn_min,#btn_max { background-color: #303030; } QPushButton#btn_min:hover { background-color: #454545; }");
              

              vs2019+qt vs tools
              qt 5.14.2

              This situation only occurs occasionally, so I'm sorry I couldn't find some pattern to provide more information.

              Thanks.

              C Offline
              C Offline
              ChrisW67
              wrote on last edited by
              #6

              @John-Van You are only setting the style sheet set on btn_min but complaining about the changed style of other icons. Perhaps you could post a self-contained, complete example that reproduces the failure.

              BTW, I'd try removing the half-reference to #btn_max from the style you attached to btn_min.

              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