Qt Forum

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

    qpushbutton stylesheet hover

    General and Desktop
    3
    3
    6481
    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.
    • R
      rafael last edited by

      what code do i use to change the image whenever i hover over a qpushbutton?

      ui->closebutton->setStyleSheet("QPushButton:hover{image:url(:/images/OnOffArm.png);};");

      i tried the code above it doesn't change the image when i hover the button.

      1 Reply Last reply Reply Quote 0
      • Chris Kawa
        Chris Kawa Moderators last edited by

        Depending on how you want your image displayed you should use either QPushButton:hover{ border-image: url(:/images/OnOffArm.png) } or QPushButton:hover{ background-image: url(:/images/OnOffArm.png) }.
        If you mean the button icon then you can set it with QPushButton { qproperty-icon: url(:/images/OnOffArm.png) } but for some reason it doesn't work for the :hover state. I guess you can report a bug on that.

        M 1 Reply Last reply Reply Quote 0
        • M
          maximus @Chris Kawa last edited by maximus

          I can confirm that it's possible to do and hover is working on my side

          Here is a working example from my project:

                   ui->pushButton_config->setStyleSheet("QPushButton#pushButton_config{image: url(:/image/icon/conf2);border-radius: 1px;}"
                                                   "QPushButton#pushButton_config:hover{image: url(:/image/icon/conf2);border-radius: 1px;}");
          

          in Designer :

          <code>
          /* MINIMIZE */
          QPushButton#pushButton_minimize {
          image: url(:/image/icon/min1);
          border-radius: 1px;
          }

          QPushButton#pushButton_minimize:hover {
          image: url(:/image/icon/min2);
          border-radius: 1px;
          }
          </code>


          Free Indoor Cycling Software - https://maximumtrainer.com

          1 Reply Last reply Reply Quote 0
          • First post
            Last post