Results 1 to 3 of 3

Thread: context menu for table

  1. #1
    Join Date
    Sep 2010
    Location
    Bangalore
    Posts
    169
    Thanks
    59
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default context menu for table

    hi everyone,
    I create a context menu for a dialog .It is working fine.But my problem is to restrict within the table view.
    Qt Code:
    1. QMenu menu(this);
    2. menu.addAction(deleteAct);
    3. menu.exec(event->globalPos());
    To copy to clipboard, switch view to plain text mode 

    Here i am using globalpos() .but i dont know what to use to restrict it.

    plz gvie some soln.

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: context menu for table

    Have a look at QWidget::mapFromGlobal().
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Sep 2010
    Location
    Bangalore
    Posts
    169
    Thanks
    59
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: context menu for table

    thanks for reply.
    Actually i got the answer.
    ie.
    Qt Code:
    1. item = new QAction(QIcon("icon_image.png"), "Item Name", this);
    2. connect(item, SIGNAL(triggered()), this, SLOT(on_actionTaken_clicked()));
    3. this->ui->tableView->addAction(item);
    4. this->ui->tableView->setContextMenuPolicy(Qt::ActionsContextMenu);
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Context menu on tab
    By wolfi3b in forum Newbie
    Replies: 2
    Last Post: 18th October 2010, 17:35
  2. Context menu
    By dejvis in forum Newbie
    Replies: 2
    Last Post: 20th September 2009, 22:02
  3. Shortcut key for context menu
    By darshan.hardas in forum Qt Programming
    Replies: 1
    Last Post: 28th December 2008, 20:32
  4. Qwt and context menu
    By giusepped in forum Qwt
    Replies: 1
    Last Post: 9th December 2008, 08:55
  5. Context Menu
    By RY in forum Newbie
    Replies: 1
    Last Post: 10th September 2008, 07:59

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.