The QMenu will not show immediately, why?
When I pressed the right mouse button, I will let the QMenu.exec(). I could not see the menu immediately. After I moved the mouse, then the menu will show. Why? Could anyone give me an idea? How to find the problem. It's very difficulty to debug at this time. Thank you!
Re: The QMenu will not show immediately, why?
Show your code where you exec menu
Re: The QMenu will not show immediately, why?
I have met the same problem, let me show my code.
QCursor cur = this->cursor();
PopMenu *menu = new PopMenu(this);
QAction* activeAction = menu->exec(cur.pos());
class MyIconStyle : public QPlastiqueStyle
{
Q_OBJECT
public:
virtual int pixelMetric(PixelMetric metric, const QStyleOption * option, const QWidget * widget) const;
};
class MyMenu : public QMenu
{
Q_OBJECT
public:
explicit MyMenu(QWidget *parent);
protected:
MyIconStyle *m_pMyStyle;
};
class PopMenu : public MyMenu
{
Q_OBJECT
public:
explicit PopMenu(QWidget *parent);
protected:
QAction *action1;
QAction *action2;
//sub_menus
QAction *sub_action_16[2];
QAction *sub_action_24[2];
QLabel *label_title;
bool eventFilter(QObject *obj, QEvent *event);
public slots:
void triggeredDeal(QAction *action);
};
Re: The QMenu will not show immediately, why?
1) use code tags.
2) just writing
QCursor cur = this->cursor();
PopMenu *menu = new PopMenu(this);
QAction* activeAction = menu->exec(cur.pos());
provides no context at all as to where and how your code is called.
With that said, I don't know why you would be experiencing a delay before the menu is shown.
Re: The QMenu will not show immediately, why?
the PopMenu is a class derived the QMenu. In the contextMenuEvent of the DisplayWindow, the code is called . The menu is not immediately shown. After moved the mouse, then the menu will show. It's seem like a problem of render because the cpu is used for decoding the multi-channel
realtime stream & the gpu is used for rendering the YUV on the DisplayWindow at the same time. I find that if I reduce the channels from 8 to 6,the popmenu is immediately shown.
Code:
{
PopMenu *menu = new PopMenu(this);
QAction* activeAction
= menu
->exec
(cur.
pos());
}
.h file
Code:
{
Q_OBJECT
public:
virtual int pixelMetric
(PixelMetric metric,
const QStyleOption * option,
const QWidget * widget
) const;
};
class MyMenu
: public QMenu{
Q_OBJECT
public:
protected:
MyIconStyle *m_pMyStyle;
};
class PopMenu : public MyMenu
{
Q_OBJECT
public:
protected:
//sub_menus
public slots:
void triggeredDeal
(QAction *action
);
};