PDA

View Full Version : Animating QToolBar's position?



qtstarter121
12th July 2017, 15:59
I have a QToolBar widget added to a QMainWindow, and it appears docked on the top of the window.

My toolbar consists of two rows in a grid layout that contain QToolButtons. I wish to first move my QToolBar up a bit so that only the second row of buttons is visible and then have the toolbar move down to reveal the entire toolbar upon mouse hovering over the top.

I attempted to use the
move(int x, int y) function provided by QWidget as follows:



toolbar->move(toolbar->pos().x(),toolbar->pos().y()-5);


but unfortunately it doesn't move. My toolbar is set to floatable as well( which i believe it is by default).

I have also attempted to do the following in the hopes of getting it to work with the toolbar undocked, however undocking the widget just places it in a separate window whereas I need it to be integrated into my QMainWindow:


toolbar->setWindowFlags(Qt::Window | Qt::FramelessWindowHint);


Any help would be greatly appreciated.

d_stranz
12th July 2017, 21:52
The position of the toolbar when docked is controlled by the main window. The toolbar can't tell itself to move, because the main window won't let it. In any case, what you are trying to do probably won't work anyway. I am not sure if there is a standard Qt widget that you could use to accomplish this type of UI.