Results 1 to 2 of 2

Thread: Animating QToolBar's position?

  1. #1
    Join Date
    Jul 2017
    Qt products

    Default Animating QToolBar's position?

    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
    Qt Code:
    1. move(int x, int y)
    To copy to clipboard, switch view to plain text mode 
    function provided by QWidget as follows:

    Qt Code:
    1. toolbar->move(toolbar->pos().x(),toolbar->pos().y()-5);
    To copy to clipboard, switch view to plain text mode 

    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:
    Qt Code:
    1. toolbar->setWindowFlags(Qt::Window | Qt::FramelessWindowHint);
    To copy to clipboard, switch view to plain text mode 

    Any help would be greatly appreciated.

  2. #2
    Join Date
    Jan 2008
    Alameda, CA, USA
    Thanked 864 Times in 851 Posts
    Qt products

    Default Re: Animating QToolBar's position?

    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.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Replies: 2
    Last Post: 10th October 2013, 16:08
  2. animating a QGraphicsObject
    By tommy22 in forum Qt Programming
    Replies: 4
    Last Post: 7th January 2013, 12:20
  3. QToolbar initial position
    By sandytang in forum Newbie
    Replies: 0
    Last Post: 10th August 2011, 02:40
  4. Position of qActions inside a QToolBar
    By jano_alex_es in forum Newbie
    Replies: 9
    Last Post: 23rd April 2010, 11:29

Tags for this Thread


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.