Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add separator to actions of a QTableView?

Tags:

qt4

qtableview

In QMenu there's a addSeparator() function available, what's the equivalent in QTableView?

I only see the function to add an action (which is addAction()), how am I supposed to add a separator when I set context menu mode to ActionContextMenu?

like image 709
daisy Avatar asked Oct 27 '25 10:10

daisy


2 Answers

QAction *separator = new QAction(this);
separator->setSeparator(true);
addAction(separator);
like image 160
Galadrius Krunthar Avatar answered Oct 29 '25 05:10

Galadrius Krunthar


I think you can set ContextMenuPolicy to Qt::CustomContextMenu and then construct your custom menu using QWidget::actions() and your separators.

like image 43
hank Avatar answered Oct 29 '25 07:10

hank



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!