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!
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,
_
Re: How to hide the mainToolBar automatically?
Is there anyway you can give me a code example,please?
Re: How to hide the mainToolBar automatically?
Something like;
QMainWindow::menuBar()->hide();
You can do it from the designer as well.
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?
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.
Re: How to hide the mainToolBar automatically?
Thank you.I will try it in both way: )
Re: How to hide the mainToolBar automatically?
1) enable mouse tracking, see QWidget::setMouseTracking()
2) overwrite mouseMoveEvent()
3) check QMouseEvent::pos()
Cheers,
_