Results 1 to 4 of 4

Thread: problem with menu entries for mdi windows

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    Join Date
    Oct 2006
    Posts
    279
    Thanks
    6
    Thanked 40 Times in 39 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: problem with menu entries for mdi windows

    You must have missed the MDI example.
    Qt Code:
    1. // during construction:
    2. connect(windowMenu, SIGNAL(aboutToShow()), this, SLOT(updateWindowMenu()));
    3.  
    4. void MainWindow::updateWindowMenu()
    5. {
    6. windowMenu->clear();
    7. windowMenu->addAction(closeAct);
    8. windowMenu->addAction(closeAllAct);
    9. windowMenu->addSeparator();
    10. windowMenu->addAction(tileAct);
    11. windowMenu->addAction(cascadeAct);
    12. windowMenu->addSeparator();
    13. windowMenu->addAction(nextAct);
    14. windowMenu->addAction(previousAct);
    15. windowMenu->addAction(separatorAct);
    16.  
    17. QList<QMdiSubWindow *> windows = mdiArea->subWindowList();
    18. separatorAct->setVisible(!windows.isEmpty());
    19.  
    20. for (int i = 0; i < windows.size(); ++i) {
    21. MdiChild *child = qobject_cast<MdiChild *>(windows.at(i)->widget());
    22.  
    23. QString text;
    24. if (i < 9) {
    25. text = tr("&%1 %2").arg(i + 1)
    26. .arg(child->userFriendlyCurrentFile());
    27. } else {
    28. text = tr("%1 %2").arg(i + 1)
    29. .arg(child->userFriendlyCurrentFile());
    30. }
    31. QAction *action = windowMenu->addAction(text);
    32. action->setCheckable(true);
    33. action ->setChecked(child == activeMdiChild());
    34. connect(action, SIGNAL(triggered()), windowMapper, SLOT(map()));
    35. windowMapper->setMapping(action, windows.at(i));
    36. }
    37. }
    To copy to clipboard, switch view to plain text mode 

  2. The following user says thank you to spud for this useful post:

    y.shan (18th September 2007)

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.