PDA

View Full Version : How to add a menu bar to fullscreen Qmainwindow?



ram4soft
27th February 2011, 09:13
Hi,
How to add a menu bar to fullscreen Qmainwindow?
thanks
Ram

wysota
27th February 2011, 09:36
Create a menu bar widget and add it to main window's layout.

nish
28th February 2011, 09:41
what exactly is the problem? does your menu disappear on full screen?

ram4soft
28th February 2011, 10:22
yes it appears without problem in the normal window but with the full it didn't
thanks

nish
28th February 2011, 10:34
how did you add your menubar? using QMainWindow::menuBar()?

ram4soft
28th February 2011, 11:51
thanks nish,
i'm using this

QMenuBar *menuBar1 = new QMenuBar(0);

fileMenu = menuBar()->addMenu(tr("&File"));

QAction* exit = new QAction(tr("&Exit"),this);
exit->setShortcuts(QKeySequence::Close);
exit->setStatusTip(tr("exit now"));
// menuBar()->addAction(exit);
fileMenu->addAction(exit);
connect(exit, SIGNAL(triggered()), this, SLOT(close()));
menuBar1->addMenu(fileMenu);
it is working fine in case of normal screen but on the fullscreen it is shown in the top of screen
all what i need is to make menu bar (options-back) on the normal position of the bottom of screen

thanks
Ram

nish
28th February 2011, 12:02
menuBar() creates AND puts it in the default layout of mainwindow at the top. Do not manipulate it. Unfortunately it always sits on the top of the window.

ram4soft
28th February 2011, 12:14
thanks nish,
i solved it right now by writing this snippet code and it shows me the device softkeys with fullscreen mode

fileMenu = menuBar()->addMenu(tr("&File"));
QAction* exit = new QAction(tr("&Exit"), this);
fileMenu->addAction(exit);

Qt::WindowFlags flags;

flags |= Qt::WindowSoftkeysVisibleHint;
flags &= ~Qt::WindowSoftkeysRespondHint;
setWindowFlags(flags); // Hides visible window
showFullScreen();
but the problem now is how to replace the "options-exit" menu with "options-back" or "back" soft key only

Ram

nish
28th February 2011, 12:20
now read your first post again... how in this great world we will know that you were talking about a mobile application? Qt is not just for mobile.

ram4soft
28th February 2011, 12:34
i'm so sorry about confusion :(

wysota
28th February 2011, 19:53
i'm so sorry about confusion :(

Stating in your profile that you use Qt for every possible platform (which is doubtful) doesn't help too.