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
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved General and Desktop
23 Posts 14 Posters 13.5k Views
  • 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.
  • 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