Results 1 to 3 of 3

Thread: QMdiArea, context menu for tabs

  1. #1
    Join Date
    Nov 2008
    Posts
    2
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QMdiArea, context menu for tabs

    Got a QMdiArea in tabbed view.
    When I right-click the tabs, a context menu with "restore" and "close" is shown.

    How do I extend this menu with e.g. "close all"?

  2. #2
    Join Date
    Mar 2007
    Posts
    57
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QMdiArea, context menu for tabs

    Take a look at the docs for QWidget::contextMenuEvent or QWidget::customContextMenuRequested. I think one of these will do the trick for you.

  3. #3
    Join Date
    Sep 2011
    Posts
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QMdiArea, context menu for tabs

    Exam:

    QMdiArea *mdiArea = new QMdiArea(this);
    QMdiAreaSubWindow *subWindow = mdiArea->addSubWindow(some_widget);
    QMenu *menu = subWindow->systemMenu();
    QAction *closeAll = new QAction(tr("Close All"),menu);
    menu->addAction(closeAll);

    connect(closeAll, SIGNAL(triggered()), mdiArea, SLOT(closeAllSubWindows()));

    it should work.

Similar Threads

  1. problem with Context Menu in QTableWidget
    By andreime in forum Newbie
    Replies: 6
    Last Post: 7th September 2015, 08:44
  2. Context Menu on QTableWidget
    By ankurjain in forum Qt Programming
    Replies: 9
    Last Post: 17th December 2009, 09:52
  3. Custom context menu in QTreeView
    By ttvo in forum Qt Programming
    Replies: 5
    Last Post: 3rd April 2009, 22:29
  4. Shortcut key for context menu
    By darshan.hardas in forum Qt Programming
    Replies: 1
    Last Post: 28th December 2008, 20:32
  5. Replies: 4
    Last Post: 25th June 2007, 20:40

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.