Results 1 to 5 of 5

Thread: How to show SubMenu next to MainMenu?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to show SubMenu next to MainMenu?

    Can u post the code how you are doing it ?

  2. #2
    Join Date
    Jul 2008
    Posts
    14
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to show SubMenu next to MainMenu?

    The code is below. Some things are missing, but I hope it's clear.. Thanks!

    Qt Code:
    1. void Tray::createMenu()
    2. {
    3. trayIconMenu = new QMenu(this);
    4. fileMenu = trayIconMenu->addMenu("Change active profile");
    5. connect(fileMenu, SIGNAL(aboutToShow()), this, SLOT(activateFileMenu()));
    6.  
    7. trayIcon = new QSystemTrayIcon(this);
    8. trayIcon->setContextMenu(trayIconMenu);
    9. }
    10.  
    11. void Tray::activateFileMenu()
    12. {
    13. fileMenu->clear();
    14. QList<QString> allfiles = files->getAllFiles(); // retrieve file names
    15. fileGroupAction = new QActionGroup(this);
    16. QAction *fileAction;
    17. for (int i = 0; i < allfiles.size(); ++i) { // create a certain number of actions in fileMenu
    18. fileAction = new QAction (files->getIcon(allfiles.at(i)), allfiles.at(i), fileGroupAction);
    19. fileAction->setCheckable(true);
    20. if (files->getImportance(allfiles.at(i))==1)
    21. fileAction->setChecked(true); // one of the files is checked by default
    22. fileMenu->addAction(fileAction);
    23. fileGroupAction->addAction(fileAction);
    24. connect(fileAction, SIGNAL(triggered()), this, SLOT(changeActiveFile()));
    25. }
    26. }
    To copy to clipboard, switch view to plain text mode 

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
  •  
Qt is a trademark of The Qt Company.