huy nguyen
huy nguyen

Reputation: 9

Connect not working in class with qt creator

Can anyone tell me a new question! I create a new class and connect when the user right-clicks, it runs into the prepareMenu slot. But when I run it, it doesn't work.Normally,I put it in MainWindow and it runs ok. Can anyone guide me how to fix it? enter image description here Run Image enter image description here

Can anyone guide me how to fix it?

Upvotes: 0

Views: 50

Answers (1)

Top-Master
Top-Master

Reputation: 8816

Try something like:

treeV3->setContextMenuPolicy(Qt::CustomContextMenu);
connect(treeV3, &QTreeView::customContextMenuRequested, this, &TestConnect::prepareMenu);

There are different policies and/or modes, one of them is "CustomContextMenu".

Upvotes: 1

Related Questions