fix weird overlay behavior in Icon Menu example widget
This commit is contained in:
parent
75d4dd7194
commit
267cceb4e7
|
@ -6,8 +6,7 @@
|
|||
MenuOverlay::MenuOverlay(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
//setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
//setAttribute(Qt::WA_NoSystemBackground);
|
||||
setAttribute(Qt::WA_NoSystemBackground);
|
||||
}
|
||||
|
||||
MenuOverlay::~MenuOverlay()
|
||||
|
@ -32,11 +31,15 @@ IconMenu::~IconMenu()
|
|||
{
|
||||
}
|
||||
|
||||
void IconMenu::setOverlayParent(QWidget *parent)
|
||||
{
|
||||
_menuOverlay->setParent(parent);
|
||||
}
|
||||
|
||||
bool IconMenu::event(QEvent *event)
|
||||
{
|
||||
if (QEvent::ParentChange == event->type()) {
|
||||
_menuOverlay->setParent(parentWidget());
|
||||
|
||||
setOverlayParent(parentWidget());
|
||||
QSize hint = _menu->layout()->sizeHint();
|
||||
_menuOverlay->setGeometry(0, 0, hint.width(), hint.height());
|
||||
}
|
||||
|
|
|
@ -23,6 +23,8 @@ public:
|
|||
explicit IconMenu(const QIcon &icon, QWidget *parent = 0);
|
||||
~IconMenu();
|
||||
|
||||
void setOverlayParent(QWidget *parent);
|
||||
|
||||
protected:
|
||||
bool event(QEvent *event) Q_DECL_OVERRIDE;
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ IconMenuExamples::IconMenuExamples(QWidget *parent)
|
|||
frame->setWidget(view);
|
||||
|
||||
layout->addWidget(frame);
|
||||
iconMenu->setOverlayParent(frame);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue