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. How to extend button size on hover event?
Forum Updated to NodeBB v4.3 + New Features

How to extend button size on hover event?

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 2.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.
  • S Offline
    S Offline
    Suares
    wrote on 20 Apr 2018, 12:14 last edited by
    #1

    For example, there is some kind of docked application. It is pinned to the right border of the screen after launching. It contains only a list of buttons/icons. When the user hovers on the icon it should be extended, for example

    alt text

    At the end, the user can click on it and appropriate dialog should appear on the screen.

    How do you think what Qt features I should use to do it?

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 20 Apr 2018, 12:43 last edited by
      #2

      Hi
      If you want a nice effect, then use QAnimation to extend it.
      If placed in layout you can animate minimum size or else simply use resize.
      It should not be super complicated to program.

      S 1 Reply Last reply 20 Apr 2018, 13:29
      3
      • M mrjj
        20 Apr 2018, 12:43

        Hi
        If you want a nice effect, then use QAnimation to extend it.
        If placed in layout you can animate minimum size or else simply use resize.
        It should not be super complicated to program.

        S Offline
        S Offline
        Suares
        wrote on 20 Apr 2018, 13:29 last edited by
        #3

        @mrjj,

        Ok, thank you!

        I am going to check it. If you saw some kind of such examples I would be appreciated you.

        M 1 Reply Last reply 20 Apr 2018, 13:34
        0
        • S Suares
          20 Apr 2018, 13:29

          @mrjj,

          Ok, thank you!

          I am going to check it. If you saw some kind of such examples I would be appreciated you.

          M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 20 Apr 2018, 13:34 last edited by
          #4

          @Suares
          Well this might be starting point.

          include <QtGui>
          include <QPushButton>
          include <QPropertyAnimation>
          include <QDebug>
          int main(int argc, char *argv[]) {
          
             QApplication a(argc, argv);
             QWidget w;
             w.setFixedSize(200,200);
             w.show();
             QPushButton button("B",&w);
             button.setFixedSize(20,20);
             button.show();
             QPropertyAnimation animation(&button, "geometry");
             animation.setDuration(5000);  //2000 miliseconds = 2 seconds
             animation.setStartValue(QRect(0,0, button.width(),button.height()));
             animation.setEndValue(QRect(180,180, button.width(),button.height()));
             animation.start();
             return a.exec();
          }
          

          Note its just sample i found fast. not tested :)
          If you move code to other function, be sure to NEW the QPropertyAnimation as else it runs out of scope.
          (ask if u dont know what i mean)

          1 Reply Last reply
          2

          1/4

          20 Apr 2018, 12:14

          • Login

          • Login or register to search.
          1 out of 4
          • First post
            1/4
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved