Results 1 to 8 of 8

Thread: How to hide the mainToolBar automatically?

  1. #1
    Join Date
    Nov 2013
    Posts
    11
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Question How to hide the mainToolBar automatically?

    I am new to Qt,and i am doing a project now.There is a requirement that toolBar could be hided automatically,and when cursor is near the topToolBarArea toolBar show itself.I am afraid to say that it's really not a difficult feature or function,but i really need help here!

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to hide the mainToolBar automatically?

    You will need to implement some mouse event handling, for example in your main window class.

    You initially hide the toolbar and show it when the mouse moves into the target area.

    Cheers,
    _

  3. #3
    Join Date
    Nov 2013
    Posts
    11
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to hide the mainToolBar automatically?

    Is there anyway you can give me a code example,please?

  4. #4
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: How to hide the mainToolBar automatically?

    Something like;

    QMainWindow::menuBar()->hide();

    You can do it from the designer as well.

  5. #5
    Join Date
    Nov 2013
    Posts
    11
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to hide the mainToolBar automatically?

    What I really need is to show the ToolBar when the mouse cursor moves to some specific area.Would you give me some suggestions?

  6. #6
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: How to hide the mainToolBar automatically?

    Oh I see...To do so you need to handle mouse events in the regarding ui's controller class. You can do it in various ways.

    1. You can reimplement QWdiget::mouseMoveEvent(QmouseEvent* e).

    2. You can use eventFilter() method along with installEventfilter()

    You can get the current mouse position from both ways above and compare the position if it's on your widget. Then you can show/hide the toolbar.

  7. The following user says thank you to zgulser for this useful post:

    drunknight (3rd December 2013)

  8. #7
    Join Date
    Nov 2013
    Posts
    11
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to hide the mainToolBar automatically?

    Thank you.I will try it in both way: )

  9. #8
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to hide the mainToolBar automatically?

    1) enable mouse tracking, see QWidget::setMouseTracking()
    2) overwrite mouseMoveEvent()
    3) check QMouseEvent:os()

    Cheers,
    _

Similar Threads

  1. qt creator 2.5 is getting closed automatically..
    By narlapavan in forum Qt Tools
    Replies: 1
    Last Post: 26th August 2012, 15:13
  2. qt creator 2.5 is getting closed automatically..
    By narlapavan in forum Qt Programming
    Replies: 1
    Last Post: 26th August 2012, 00:23
  3. Replies: 3
    Last Post: 5th August 2009, 22:15
  4. How to launch an application automatically ?
    By merry in forum Qt Programming
    Replies: 5
    Last Post: 16th January 2009, 16:26
  5. library not build automatically
    By KoosKoets in forum Qt Programming
    Replies: 1
    Last Post: 26th March 2007, 14:43

Tags for this Thread

Bookmarks

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.