gui developer
24th September 2010, 14:45
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:
class ContextMenuTabWidget : public QTabWidget
{
Q_OBJECT
public:
ContextMenuTabWidget(QWidget * parent = 0);
public slots:
void showContextMenu(const QPoint& 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));
}
How can I avoid the problem of the tab keeping its hover style?
Thanks in advance!
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:
class ContextMenuTabWidget : public QTabWidget
{
Q_OBJECT
public:
ContextMenuTabWidget(QWidget * parent = 0);
public slots:
void showContextMenu(const QPoint& 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));
}
How can I avoid the problem of the tab keeping its hover style?
Thanks in advance!