Results 1 to 6 of 6

Thread: Hide Qmenubar

  1. #1
    Join Date
    Jan 2007
    Posts
    92
    Thanks
    14
    Thanked 1 Time in 1 Post

    Default Hide Qmenubar

    Hi Guys,

    I am having little problem with QMenubar on QMainWindow. I have been using Qt4. I have couple QActions and menus added to menubar. I am able to access all action slots such as ( Ctl+N) New or Clt+S (Save) that have added to menubar in normal window screen. But as soon as I switched to full screen mode and I am not able to get actions to working (Ctl+N or CLT+S) . Because I beleive QMenubar is part of mainwindow and actions are added on top of that to menuBar. Is there any way to access menuItems from menubar even it is hidden in full screen mode? It works fine in Qt3.

    Here's the code snippet:-

    mainWindow is QMainWindow

    QMenuBar * pMenuBar = mainWindow->menuBar();

    Qt Code:
    1. void CMainClass::ToggleSlot()
    2. {
    3.  
    4. if(mainWindow->windowState() & Qt::WindowFullScreen) // Show normal
    5. {
    6.  
    7. if(pMenuBar)
    8. {
    9. m_pMenuBar->show(); //Everything works fine
    10. }
    11. }
    12.  
    13. else //Show FullScreen
    14. {
    15.  
    16. if(pMenuBar)
    17. {
    18. m_pMenuBar->hide(); //Unable to acces menu items
    19.  
    20. }
    21.  
    22. }
    23.  
    24. mainWindow->setWindowState( mainWindow->windowState() ^Qt::WindowFullScreen );
    25. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Hide Qmenubar

    Have you seen QWidget::showFullScreen()?
    Last edited by wysota; 10th December 2008 at 10:13.

  3. #3
    Join Date
    Jan 2007
    Posts
    92
    Thanks
    14
    Thanked 1 Time in 1 Post

    Default Re: Hide Qmenubar

    I tried showFullScreen() method..it shows full screen mode with menu hidden but still I am not able to get ctrl actions to work.

    I did like this:-

    Qt Code:
    1. if(mainWindow->windowState() & Qt::WindowFullScreen) // Show normal
    2. {
    3.  
    4. if(pMenuBar)
    5. {
    6. pMenuBar->show(); //Everything works fine
    7.  
    8. }
    9.  
    10. mainWindow->showNormal();
    11.  
    12. }
    13.  
    14. else //show full screen
    15. {
    16. if( pMenuBar )
    17. {
    18. pMenuBar->hide();
    19. }
    20. mainWindow->showFullScreen();
    21.  
    22. }
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Hide Qmenubar

    If you hide the menu bar, its actions won't work, regardless of the state of the window.

  5. The following user says thank you to wysota for this useful post:

    user_mail07 (10th December 2008)

  6. #5
    Join Date
    Jan 2007
    Posts
    92
    Thanks
    14
    Thanked 1 Time in 1 Post

    Default Re: Hide Qmenubar

    Ok ,thanks wysota. It used to work in qt3 but I think functionality has been changed now. SO there is no workaround if still want to hide menubar?

  7. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Hide Qmenubar

    Place the actions elsewhere, for example in a toolbar or something. Try adding them directly to the window too.

Similar Threads

  1. Replies: 10
    Last Post: 20th April 2015, 22:24
  2. Hide widget, but not change layout
    By dimaz in forum Qt Programming
    Replies: 3
    Last Post: 21st November 2008, 14:32
  3. unable to hide combobox or spinbox in toolbar
    By Sandip in forum Qt Programming
    Replies: 1
    Last Post: 22nd July 2008, 11:52
  4. Hide qtreewidgetitem root
    By altVis in forum Qt Programming
    Replies: 1
    Last Post: 27th March 2008, 11:24
  5. model/view, can't hide row/col
    By grellsworth in forum Qt Programming
    Replies: 7
    Last Post: 17th September 2007, 14:21

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.