[Solved] First menu on menubar not activating when moused over
-
Saved my life...ops .. I mean saved lots of my time
thank you
[quote author="blane245" date="1314113867"]I was working on getting you a copy with just the menu problem and not all of the application guts when I found one of my objects that was making the main window a parent. When I removed the relationship the menu starting working. My object was not a widget and does not need the window to own it. Problem solved. Thanx for leading me into the solution.
I guess I need to read up on parent/child relationships in Qt.[/quote]
-
This is the gift that keeps on giving. Ran into this problem today and would have never solved it without this thread. Thanks!!!
-
This thread helped me to get to the problem. I would like to propose a quick way to find the solution that worked for me since I had such a big project and many children widgets.
If you know how to subclass an event filter it's pretty simple...
PART 1) in EventFilter.h
#define EVENTFILTER_H #include <QWidget> #include <QDebug> #include <QEvent> class EventFilter : public QWidget { Q_OBJECT public: explicit EventFilter(QWidget *parent = 0); signals: protected: bool eventFilter(QObject *target, QEvent *event); }; #endif // EVENTFILTER_H
PART 2) in EventFilter.cpp
EventFilter::EventFilter(QWidget *parent): QWidget(parent) { } bool EventFilter::eventFilter(QObject *target, QEvent *event) { if (event->type() == QEvent::KeyPress) { QPoint p = QCursor::pos(); QWidget *w = QApplication::widgetAt(p); qDebug() << w; } }
PART 3) in your mainwindow constructor or w/e you load up settings
#include "EventFilter.h" EventFilter* myFilter = new EventFilter(); this->installEventFilter(myFilter);
PART 4) go hunting with your new invisible widget detector!
Just hover your mouse over the defective file menu items and press your spacebar, it should output the topmost offending widget to the console for you to know what you are looking for. In my case it was ANOTHER eventfilter that I had parented mistakenly way back when. Happy hunting!
If you have a small project just use previous methods should be simple enough.
-
This thread helped me to get to the problem. I would like to propose a quick way to find the solution that worked for me since I had such a big project and many children widgets.
If you know how to subclass an event filter it's pretty simple...
PART 1) in EventFilter.h
#define EVENTFILTER_H #include <QWidget> #include <QDebug> #include <QEvent> class EventFilter : public QWidget { Q_OBJECT public: explicit EventFilter(QWidget *parent = 0); signals: protected: bool eventFilter(QObject *target, QEvent *event); }; #endif // EVENTFILTER_H
PART 2) in EventFilter.cpp
EventFilter::EventFilter(QWidget *parent): QWidget(parent) { } bool EventFilter::eventFilter(QObject *target, QEvent *event) { if (event->type() == QEvent::KeyPress) { QPoint p = QCursor::pos(); QWidget *w = QApplication::widgetAt(p); qDebug() << w; } }
PART 3) in your mainwindow constructor or w/e you load up settings
#include "EventFilter.h" EventFilter* myFilter = new EventFilter(); this->installEventFilter(myFilter);
PART 4) go hunting with your new invisible widget detector!
Just hover your mouse over the defective file menu items and press your spacebar, it should output the topmost offending widget to the console for you to know what you are looking for. In my case it was ANOTHER eventfilter that I had parented mistakenly way back when. Happy hunting!
If you have a small project just use previous methods should be simple enough.
-
I was working on getting you a copy with just the menu problem and not all of the application guts when I found one of my objects that was making the main window a parent. When I removed the relationship the menu starting working. My object was not a widget and does not need the window to own it. Problem solved. Thanx for leading me into the solution.
I guess I need to read up on parent/child relationships in Qt.
-
I was working on getting you a copy with just the menu problem and not all of the application guts when I found one of my objects that was making the main window a parent. When I removed the relationship the menu starting working. My object was not a widget and does not need the window to own it. Problem solved. Thanx for leading me into the solution.
I guess I need to read up on parent/child relationships in Qt.