Hi,
I have added a custom context menu to the QTabWidget. However, if a user moves mouse over one of the tabs, right-clicks to display the context menu, moves the mouse away and clicks on some other control, the menu disappears but the tab keeps its hover style.
A simple example of the way I am adding the context menu is below:
{
Q_OBJECT
public:
ContextMenuTabWidget
(QWidget * parent
= 0);
public slots:
void showContextMenu(const QPoint& point);
}
class ContextMenuTabWidget : public QTabWidget
{
Q_OBJECT
public:
ContextMenuTabWidget(QWidget * parent = 0);
public slots:
void showContextMenu(const QPoint& point);
}
To copy to clipboard, switch view to plain text mode
{
connect(this, SIGNAL(customContextMenuRequested(const QPoint&)),
this, SLOT(showContextMenu(const QPoint&)));
}
void ContextMenuTabWidget::showContextMenu(const QPoint& point)
{
menu.addAction(tr("Menu Item"));
menu.exec(mapToGlobal(point));
}
ContextMenuTabWidget::ContextMenuTabWidget(QWidget * parent) : QTabWidget(parent)
{
connect(this, SIGNAL(customContextMenuRequested(const QPoint&)),
this, SLOT(showContextMenu(const QPoint&)));
}
void ContextMenuTabWidget::showContextMenu(const QPoint& point)
{
QMenu menu;
menu.addAction(tr("Menu Item"));
menu.exec(mapToGlobal(point));
}
To copy to clipboard, switch view to plain text mode
How can I avoid the problem of the tab keeping its hover style?
Thanks in advance!
Bookmarks