Results 1 to 4 of 4

Thread: [QMenu] Context menu for widget created in Qt Creator

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2009
    Posts
    51
    Thanks
    28
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default [QMenu] Context menu for widget created in Qt Creator

    I'd like to add context menus for widgets on my form.
    As I know to do that I should reimplement Widget::contextMenuEvent(QContextMenuEvent*) function.
    But how can I reimplement it if widget is created in Qt Creator (designer)?

    @EDIT
    Ok, I found out I can do it by this way:
    Qt Code:
    1. void QLineEdit::contextMenuEvent ( QContextMenuEvent * event ){
    2. QMenu *menu=new QMenu;
    3. (...)
    4. menu->exec(event->globalPos());
    5. }
    To copy to clipboard, switch view to plain text mode 
    But is there any way to set context menu for only one lineedit?
    Last edited by Macok; 4th March 2009 at 16:05.

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.