What wysota meant was removing items wont hide the menu bar..... dont question his knowledge about Qt.... I dont stand anywhere near him....
also to hide/ show the menu bar u can use some keyboard shortcuts, or provide the same from toolbar...
and if u want that some actions in the menu shouldnt work, just disable the actions....
By the way, just as a side note, possible shortcuts assigned to menu actions won't trigger while the menu bar is hidden.
J-P Nurmi
An empty menu bar is not displayed if you don't populate it, because it's not created. When you do created, things change. Anyway, if you hide the menu bar, how will you know when you want to get it back?
If you enable mouse tracking then yes. But you'll have to do it in an event filter which you have to apply on your central widget and any of its subwidgets, because if a subwidget handles a mouse move event itself, it won't propagate it to the parent. Of course you'll have to calculate the coordinates in the main window coordinate system. Lots of work![]()
See the attachment...
hope this helps![]()
viking (29th March 2007)
Thanks a ton aamer4yu for this. I really appreciate it! I tried out the app. I feel it needs some debuggings coz in the function
Qt Code:
void CMainWindow::initial() { menuBarRect = menuBar()->geometry(); menuBar()->hide(); }To copy to clipboard, switch view to plain text mode
the moment the menubar hides, the Y2 in the geometry becomes -1. hence, goin forward,
control never enters the if part, it always goes into the else. i'll look into it. of course your inputs would be valuable.Qt Code:
if(menuBarRect.contains(mousePos) ) { menuBar()->show(); isMenuOn = true; } else { menuBar()->hide(); isMenuOn = false; }To copy to clipboard, switch view to plain text mode
as i replied to wysota, i actually want to implement the trapezoidal menubar that appears on the top when you connect to Remote Desktop in Windows. the one with a fancy PIN button that toggles autohide... still searching for a way to do that... any help wud be appreciated!![]()
Seems u havent understood my program or I have understood what u wanted.
I implemented auto hide like in taskbar in windows.
What I do is, initially using the single shot timer I capture the geometry of the menubar. This is a private member, so its value is retained. As soon as I set the geometry cordinated in menuBarRect, I hide the menubar. So u wont see a menubar initially.
When u move the mouse in the upper part of the window, where the menu is supposed to appear, I capture it, and show the menubar.
Did u try running the code ?? or u just walked thru manually ?? also isMenuOn variable is not needed. I was just trying with that variable, and forgot to delete it.
Also I havent seen your "trapezoidal menubar that appears on the top when you connect to Remote Desktop in Windows." so cant help u on that right now...
if u have problem in running my code, ask me....![]()
what error were u getting before editing the code ??
it was working fine for me...
keep in mind that MouseMoveEvents only get passed when they move over the widget's editable boxes unless you have a mouse button pressed down.
Because of this, your scrollbars and stuff like that don't process mousemove or mousepress events, AFAIK. I would assume it's the same way with the titlebar.
Of course, I've never enabled mousemovement on a central widget so I don't know what kind of effect that will have on subchildren. Good luck getting this working.
This post is really helpful!
I applied it and it worked fine in Linux version.
However it does not work in windows!
the menu bar never appears, does this have to do with the coordinates of the windows screen?!
@ I did! And I ran it in debug mode as well. Thats when i found out that the control never enters to the part where it is supposed to show the menubar.
@ I'll try to send you a screenshot of that "trapezoidal menubar that appears on the top when you connect to Remote Desktop in Windows." But hey, thanks for all the time man! Appreciate it a lot !!!![]()
It does enter.... move the mouse close to the title bar....@ I did! And I ran it in debug mode as well. Thats when i found out that the control never enters to the part where it is supposed to show the menubar.
what platform are u using by the way ? I tried on windows with Qt 4.2.0 and its working fine for me. The menu shows up when u move the mouse just below the title bar area, where it shud appear
Bookmarks