PDA

View Full Version : Hide Qmenubar



user_mail07
10th December 2008, 01:37
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();


void CMainClass::ToggleSlot()
{

if(mainWindow->windowState() & Qt::WindowFullScreen) // Show normal
{

if(pMenuBar)
{
m_pMenuBar->show(); //Everything works fine
}
}

else //Show FullScreen
{

if(pMenuBar)
{
m_pMenuBar->hide(); //Unable to acces menu items

}

}

mainWindow->setWindowState( mainWindow->windowState() ^Qt::WindowFullScreen );
}

wysota
10th December 2008, 10:06
Have you seen QWidget::showFullScreen()?

user_mail07
10th December 2008, 20:56
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:-


if(mainWindow->windowState() & Qt::WindowFullScreen) // Show normal
{

if(pMenuBar)
{
pMenuBar->show(); //Everything works fine

}

mainWindow->showNormal();

}

else //show full screen
{
if( pMenuBar )
{
pMenuBar->hide();
}
mainWindow->showFullScreen();

}

wysota
10th December 2008, 21:06
If you hide the menu bar, its actions won't work, regardless of the state of the window.

user_mail07
10th December 2008, 21:09
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?

wysota
10th December 2008, 22:16
Place the actions elsewhere, for example in a toolbar or something. Try adding them directly to the window too.