Results 1 to 6 of 6

Thread: QTableWidget right click menu

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts

    Default Re: QTableWidget right click menu

    You forgot to adjust frmSettings::ProvideContexMenu(). It still takes a pointer.

    The easiest way to construct a context menu is to use Qt::ActionsContextMenu. All it takes is to add actions via QWidget::addAction() and the menu is constructed automatically for you:
    Qt Code:
    1. setContextMenuPolicy(Qt::ActionsContextMenu);
    2. QAction* fooAction = new new QAction("foo");
    3. QAction* barAction = new new QAction("bar");
    4. connect(fooAction, SIGNAL(triggered()), this, SLOT(doSomethingFoo()));
    5. connect(barAction, SIGNAL(triggered()), this, SLOT(doSomethingBar()));
    6. addAction(fooAction);
    7. addAction(barAction);
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  2. #2
    Join Date
    May 2008
    Location
    Rijeka, Croatia
    Posts
    85
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    10
    Thanked 6 Times in 6 Posts

    Default Re: QTableWidget right click menu

    Quote Originally Posted by jpn View Post
    You forgot to adjust frmSettings::ProvideContexMenu(). It still takes a pointer.
    YES! thank you. I'm used to .NET warnings for every litle thing.. so im kinda strugling with QT..
    Replies on my post where fast and exact nice forum guys!

  3. #3
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts

    Default Re: QTableWidget right click menu

    Quote Originally Posted by stefan View Post
    YES! thank you. I'm used to .NET warnings for every litle thing.. so im kinda strugling with QT..
    Signal slot connections are established at run time, that's why there is no error/warning at compilation time. Notice that QObject::connect() outputs a detailed warning in the debug output in case establishing the connection fails.

    Replies on my post where fast and exact nice forum guys!
    Thanks, you're welcome.
    J-P Nurmi

Similar Threads

  1. Context Menu on QTableWidget
    By ankurjain in forum Qt Programming
    Replies: 9
    Last Post: 17th December 2009, 09:52
  2. Replies: 2
    Last Post: 2nd April 2008, 17:28
  3. Context menu works slowly on QTableWidget
    By THRESHE in forum Qt Programming
    Replies: 3
    Last Post: 13th March 2008, 19:54
  4. Right click menu
    By ^NyAw^ in forum Qt Programming
    Replies: 4
    Last Post: 24th January 2008, 19:22
  5. QTableWidget click in empty space results in error?
    By Giel Peters in forum Qt Programming
    Replies: 4
    Last Post: 21st January 2006, 00:07

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.