PDA

View Full Version : Qmenu



deeee
24th May 2010, 01:30
hello,

how to add a horizontal line separator in a Qmenu ?
I tried this, but it doesn't work :
fileMenu->addAction(fileMenu->addSeparator());

thanks

Zlatomir
24th May 2010, 06:03
fileMenu->addSeparator(); //just this should do the trick

deeee
24th May 2010, 15:58
I did as you've said but it didn't work I don't know why.
I can add vertical separators in the tool bar but not horizontal ones in the menu.
here is what I did in the function that creates he menus :



void MainWindow::createMenus()
{
fileMenu = menuBar()->addMenu(tr("&File"));
fileMenu->addAction(newAct);
fileMenu->addAction(openAct);
fileMenu->addAction(saveAct);
fileMenu->addAction(saveAsAct);
fileMenu->addAction(solveAct);
fileMenu->addSeparator();
fileMenu->addAction(quitAct);

editMenu = menuBar()->addMenu(tr("&Edit"));
editMenu->addAction(undoAct);
editMenu->addAction(redoAct);
editMenu->addSeparator();
editMenu->addAction(cutAct);
editMenu->addAction(copyAct);
editMenu->addAction(pasteAct);
editMenu->addSeparator();
editMenu->addAction(selectAllAct);

menuBar()->addSeparator();

viewMenu = menuBar()->addMenu(tr("&View"));
viewMenu->addAction(displayEditorAct);
viewMenu->addAction(displayResultAct);

helpMenu = menuBar()->addMenu(tr("&Help"));

}

thanks in advance for your help.

deeee
27th May 2010, 01:27
It seems that I have a problem with my computer because my theme is black and thus I can't distinguish the separator .When I tested the code on an other computer it worked normally.
Any way thanks so much for your help.