PDA

View Full Version : Separator in context menu



schall_l
18th June 2009, 17:46
Hi,

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


void
CommunicationView::createContextMenu() {
addAction(highlightLogEntryAct);
addAction(deleteHighlightLogEntryAct);
// <- add separator here
addAction(deleteLogEntryAct);
setContextMenuPolicy(Qt::ActionsContextMenu);
}

If someone has an idea...

Lykurg
18th June 2009, 17:51
addSeparator()
? whats the base class of your CommunicationView or is addAction() self defined function of you?

schall_l
18th June 2009, 17:54
I've already tried this...

CommunicationView derives from QTableView


void
CommunicationView::createContextMenu() {
addAction(highlightLogEntryAct);
addAction(deleteHighlightLogEntryAct);
addSeparator();
addAction(deleteLogEntryAct);
setContextMenuPolicy(Qt::ActionsContextMenu);
}


1>Compiling...
1>CommunicationView.cpp
1>.\src\CommunicationView.cpp(93) : error C3861: 'addSeparator': identifier not found
1>Build log was saved at "file://c:\tmp\canmonitor\apps\debug\BuildLog.htm"
1>apps - 1 error(s), 0 warning(s)

Lykurg
18th June 2009, 18:09
Use:

QAction *act = new QAction(this);
act->setSeparator(true);
addAction(act);