Results 1 to 4 of 4

Thread: Separator in context menu

  1. #1
    Join Date
    Jan 2008
    Location
    Germany
    Posts
    80
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Separator in context menu

    Hi,

    I do not find how to add a separator in a contextuel menu.

    Qt Code:
    1. void
    2. CommunicationView::createContextMenu() {
    3. addAction(highlightLogEntryAct);
    4. addAction(deleteHighlightLogEntryAct);
    5. // <- add separator here
    6. addAction(deleteLogEntryAct);
    7. setContextMenuPolicy(Qt::ActionsContextMenu);
    8. }
    To copy to clipboard, switch view to plain text mode 

    If someone has an idea...

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Separator in context menu

    Qt Code:
    1. addSeparator()
    To copy to clipboard, switch view to plain text mode 
    ? whats the base class of your CommunicationView or is addAction() self defined function of you?

  3. #3
    Join Date
    Jan 2008
    Location
    Germany
    Posts
    80
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Separator in context menu

    I've already tried this...

    CommunicationView derives from QTableView

    Qt Code:
    1. void
    2. CommunicationView::createContextMenu() {
    3. addAction(highlightLogEntryAct);
    4. addAction(deleteHighlightLogEntryAct);
    5. addSeparator();
    6. addAction(deleteLogEntryAct);
    7. setContextMenuPolicy(Qt::ActionsContextMenu);
    8. }
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. 1>Compiling...
    2. 1>CommunicationView.cpp
    3. 1>.\src\CommunicationView.cpp(93) : error C3861: 'addSeparator': identifier not found
    4. 1>Build log was saved at "file://c:\tmp\canmonitor\apps\debug\BuildLog.htm"
    5. 1>apps - 1 error(s), 0 warning(s)
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Separator in context menu

    Use:
    Qt Code:
    1. QAction *act = new QAction(this);
    2. act->setSeparator(true);
    3. addAction(act);
    To copy to clipboard, switch view to plain text mode 

  5. The following user says thank you to Lykurg for this useful post:

    schall_l (19th June 2009)

Similar Threads

  1. Context Menu on QTableWidget
    By ankurjain in forum Qt Programming
    Replies: 9
    Last Post: 17th December 2009, 09:52
  2. Custom context menu in QTreeView
    By ttvo in forum Qt Programming
    Replies: 5
    Last Post: 3rd April 2009, 22:29
  3. Shortcut key for context menu
    By darshan.hardas in forum Qt Programming
    Replies: 1
    Last Post: 28th December 2008, 20:32
  4. QItemDelegate Context Menu
    By aekilic in forum Qt Programming
    Replies: 16
    Last Post: 3rd December 2008, 09:29
  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.