Results 1 to 4 of 4

Thread: Qmenu

  1. #1
    Join Date
    May 2010
    Posts
    30
    Qt products
    Qt4

    Default Qmenu

    hello,

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

    thanks

  2. #2
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Qmenu

    fileMenu->addSeparator(); //just this should do the trick

  3. #3
    Join Date
    May 2010
    Posts
    30
    Qt products
    Qt4

    Default Re: Qmenu

    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 :


    Qt Code:
    1. void MainWindow::createMenus()
    2. {
    3. fileMenu = menuBar()->addMenu(tr("&File"));
    4. fileMenu->addAction(newAct);
    5. fileMenu->addAction(openAct);
    6. fileMenu->addAction(saveAct);
    7. fileMenu->addAction(saveAsAct);
    8. fileMenu->addAction(solveAct);
    9. fileMenu->addSeparator();
    10. fileMenu->addAction(quitAct);
    11.  
    12. editMenu = menuBar()->addMenu(tr("&Edit"));
    13. editMenu->addAction(undoAct);
    14. editMenu->addAction(redoAct);
    15. editMenu->addSeparator();
    16. editMenu->addAction(cutAct);
    17. editMenu->addAction(copyAct);
    18. editMenu->addAction(pasteAct);
    19. editMenu->addSeparator();
    20. editMenu->addAction(selectAllAct);
    21.  
    22. menuBar()->addSeparator();
    23.  
    24. viewMenu = menuBar()->addMenu(tr("&View"));
    25. viewMenu->addAction(displayEditorAct);
    26. viewMenu->addAction(displayResultAct);
    27.  
    28. helpMenu = menuBar()->addMenu(tr("&Help"));
    29.  
    30. }
    To copy to clipboard, switch view to plain text mode 

    thanks in advance for your help.

  4. #4
    Join Date
    May 2010
    Posts
    30
    Qt products
    Qt4

    Default Re: Qmenu

    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.

Similar Threads

  1. Custom QMenu
    By ArlexBee-871RBO in forum Qt Programming
    Replies: 2
    Last Post: 22nd November 2009, 00:07
  2. problem in QMenu
    By wagmare in forum Qt Programming
    Replies: 0
    Last Post: 29th January 2009, 08:56
  3. QMenu
    By khcbabu in forum Qt Programming
    Replies: 2
    Last Post: 22nd October 2008, 14:08
  4. QMenu
    By toki83 in forum Qt Programming
    Replies: 2
    Last Post: 22nd March 2008, 11:17
  5. QMenu Help pls
    By munna in forum Newbie
    Replies: 2
    Last Post: 19th March 2006, 15:36

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.