Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Solved] First menu on menubar not activating when moused over
Forum Updated to NodeBB v4.3 + New Features

[Solved] First menu on menubar not activating when moused over

Scheduled Pinned Locked Moved General and Desktop
23 Posts 14 Posters 14.0k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    Franzk
    wrote on last edited by
    #8

    "QObject::dumpObjectInfo()":http://doc.trolltech.com/latest/qobject.html#dumpObjectInfo could help.

    "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

    http://www.catb.org/~esr/faqs/smart-questions.html

    1 Reply Last reply
    0
    • B Offline
      B Offline
      blane245
      wrote on last edited by
      #9

      I've looked through the dump as you have suggested and see nothing that looks unsual as far as I can see. I don't know Qt well enough to be able to explain all of the objects. I can see all that I expect to see, but there are a number that I can't. Here's the ones that I can't explain.
      QRubberBand::qt_rubberband
      QWidget::centralWidget
      OBJECT QWidget::layoutWidget
      QToolButton::qt_menubar_ext_button
      I am using a QTableView and it seems to create a few more scroll bar and header view objects than I would expect.
      I can send the full dump, but that might be a bit much.

      1 Reply Last reply
      0
      • F Offline
        F Offline
        Franzk
        wrote on last edited by
        #10

        If possible, could you share the project so we can have a look (zipped, compiling)?

        "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

        http://www.catb.org/~esr/faqs/smart-questions.html

        1 Reply Last reply
        0
        • B Offline
          B Offline
          blane245
          wrote on last edited by
          #11

          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.

          A B 2 Replies Last reply
          0
          • F Offline
            F Offline
            Franzk
            wrote on last edited by
            #12

            Excellent. Happy it works.

            "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

            http://www.catb.org/~esr/faqs/smart-questions.html

            1 Reply Last reply
            0
            • D Offline
              D Offline
              draconis
              wrote on last edited by
              #13

              I was very happy to find this discussion on the menubar issue. I too had the same problem and I was able to track down the QWidget that was causing the problem. However, unlike the above, my widget did need to know its parent. My solution was not not pass in the parent on the constructor, but to create a variable to hold the parent and set it separately. Thanks for your help.

              1 Reply Last reply
              0
              • P Offline
                P Offline
                PSI-lbc
                wrote on last edited by
                #14

                bump...for an interesting problem. Had the same issue.

                Side note: it appears to only occur on Windows and not for MacOS code...maybe because the menu is separated from the app window?

                1 Reply Last reply
                0
                • K Offline
                  K Offline
                  kaha6uc
                  wrote on last edited by
                  #15

                  Bump from me too... two years later! I had the same problem. I was instantiating a child of a KTextEditor with "this" in the constructor. When I changed "this" to 0 the menu now works fine and is clickable and all. Thank you!

                  1 Reply Last reply
                  0
                  • R Offline
                    R Offline
                    rlopatta
                    wrote on last edited by
                    #16

                    me 2!

                    costs me several weeks of checking...

                    until I found this post.

                    thx a lot, guys!

                    Ruediger

                    1 Reply Last reply
                    0
                    • Y Offline
                      Y Offline
                      Yash
                      wrote on last edited by
                      #17

                      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]

                      http://kineticwing.com : Web IDE, QSS Editor
                      http://speedovation.com : Development Lab

                      1 Reply Last reply
                      0
                      • sonichyS Offline
                        sonichyS Offline
                        sonichy
                        wrote on last edited by
                        #18

                        I run into this problem too.
                        Change
                        label=new QLabel(this)
                        to
                        label=new QLabel;
                        This label has not add too any window, I use it to save QFont.

                        https://github.com/sonichy

                        1 Reply Last reply
                        0
                        • P Offline
                          P Offline
                          PdxEngineer
                          wrote on last edited by
                          #19

                          This is the gift that keeps on giving. Ran into this problem today and would have never solved it without this thread. Thanks!!!

                          1 Reply Last reply
                          2
                          • - Offline
                            - Offline
                            -xk-
                            wrote on last edited by -xk-
                            #20

                            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.

                            SGaistS 1 Reply Last reply
                            0
                            • - -xk-

                              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.

                              SGaistS Offline
                              SGaistS Offline
                              SGaist
                              Lifetime Qt Champion
                              wrote on last edited by
                              #21

                              @xk hi and welcome to devnet,

                              Thanks for the mini-guide. You can simplify one thing: EventFilter does not need to inherit QWidget, QObject is fine.

                              Interested in AI ? www.idiap.ch
                              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                              1 Reply Last reply
                              0
                              • B blane245

                                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.

                                A Offline
                                A Offline
                                amitkawade47
                                wrote on last edited by
                                #22

                                @blane245 @Yash Thanks. saved a lot of time. This thread is very helpful.

                                1 Reply Last reply
                                0
                                • B blane245

                                  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.

                                  B Offline
                                  B Offline
                                  Boghy
                                  wrote on last edited by
                                  #23

                                  @blane245 Thanks, lost a lot of time without figuring this out and then I found this useful thread.

                                  1 Reply Last reply
                                  0

                                  • Login

                                  • Login or register to search.
                                  • First post
                                    Last post
                                  0
                                  • Categories
                                  • Recent
                                  • Tags
                                  • Popular
                                  • Users
                                  • Groups
                                  • Search
                                  • Get Qt Extensions
                                  • Unsolved