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. [QT 5.9.7][Linux X11]Different behavior QMenu on Debug and Release build.
Forum Updated to NodeBB v4.3 + New Features

[QT 5.9.7][Linux X11]Different behavior QMenu on Debug and Release build.

Scheduled Pinned Locked Moved Solved General and Desktop
13 Posts 4 Posters 1.6k 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.
  • mranger90M Offline
    mranger90M Offline
    mranger90
    wrote on last edited by
    #4

    I'm guessing that "rect" is a variant that you are accessing to get the dimensions.
    I would check the values of access , "x", "y" and "width" and "height". Its possible that in the debug version you are getting zero as a value, but in the release version you are getting garbage that may be interpreted as a negative integer.
    In that case the position or size may not be visible.

    K 1 Reply Last reply
    0
    • Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #5

      @kas_ru what @SGaist meant was this: http://doc.qt.io/qt-5/qmenu.html#exec - exec already shows the menu...

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      1
      • mranger90M mranger90

        I'm guessing that "rect" is a variant that you are accessing to get the dimensions.
        I would check the values of access , "x", "y" and "width" and "height". Its possible that in the debug version you are getting zero as a value, but in the release version you are getting garbage that may be interpreted as a negative integer.
        In that case the position or size may not be visible.

        K Offline
        K Offline
        kas_ru
        wrote on last edited by
        #6

        @mranger90 I checked, "rect" object in Debug and Release the same.

        1 Reply Last reply
        0
        • K Offline
          K Offline
          kas_ru
          wrote on last edited by
          #7

          I think this is X11 issues.
          Last news:

          /*!
              \overload
          
              Executes this menu synchronously.
          
              Pops up the menu so that the action \a action will be at the
              specified \e global position \a p. To translate a widget's local
              coordinates into global coordinates, use QWidget::mapToGlobal().
          
              This returns the triggered QAction in either the popup menu or one
              of its submenus, or 0 if no item was triggered (normally because
              the user pressed Esc).
          
              Note that all signals are emitted as usual. If you connect a
              QAction to a slot and call the menu's exec(), you get the result
              both via the signal-slot connection and in the return value of
              exec().
          
              Common usage is to position the menu at the current mouse
              position:
              \snippet code/src_gui_widgets_qmenu.cpp 3
              or aligned to a widget:
              \snippet code/src_gui_widgets_qmenu.cpp 4
              or in reaction to a QMouseEvent *e:
              \snippet code/src_gui_widgets_qmenu.cpp 5
          
              When positioning a menu with exec() or popup(), bear in mind that
              you cannot rely on the menu's current size(). For performance
              reasons, the menu adapts its size only when necessary. So in many
              cases, the size before and after the show is different. Instead,
              use sizeHint() which calculates the proper size depending on the
              menu's current contents.
          
              \sa popup(), QWidget::mapToGlobal()
          */
          QAction *QMenu::exec(const QPoint &p, QAction *action)
          {
              Q_D(QMenu);
              ensurePolished();
              createWinId();
              QEventLoop eventLoop;
              d->eventLoop = &eventLoop;
              popup(p, action);
          
              QPointer<QObject> guard = this;
              (void) eventLoop.exec();
              if (guard.isNull())
                  return 0;
          
              action = d->syncAction; /// <================ action is 0
              d->syncAction = 0;
              d->eventLoop = 0;
              return action;
          }
          

          In QT core line: "action = d->syncAction;" action variable is 0
          Any idea?

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #8

            Were else is it modified ?

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

            K 1 Reply Last reply
            0
            • SGaistS SGaist

              Were else is it modified ?

              K Offline
              K Offline
              kas_ru
              wrote on last edited by
              #9

              @SGaist said in [QT 5.9.7][Linux X11]Different behavior QMenu on Debug and Release build.:

              Were else is it modified ?
              No

              1 Reply Last reply
              0
              • K Offline
                K Offline
                kas_ru
                wrote on last edited by
                #10

                Update Information:
                If program start by debugger (gdb program) exec() (event loop) working correctly.
                If program start without debugger exec() (event loop) immediately stop.

                I think:
                This is XCB events. We received a event which clicking outside of the client area. And after that menu (event loop stoped) is closed.

                What do you think ?

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #11

                  Does it also happen if you remove the call to popup before calling exec ?

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

                  K 1 Reply Last reply
                  0
                  • SGaistS SGaist

                    Does it also happen if you remove the call to popup before calling exec ?

                    K Offline
                    K Offline
                    kas_ru
                    wrote on last edited by
                    #12

                    @SGaist said in [QT 5.9.7][Linux X11]Different behavior QMenu on Debug and Release build.:

                    Does it also happen if you remove the call to popup before calling exec ?

                    Yes

                    1 Reply Last reply
                    0
                    • K Offline
                      K Offline
                      kas_ru
                      wrote on last edited by kas_ru
                      #13

                      Hi
                      Problem is solved.

                      Menu closed in code info Application::eventFilter( QObject* object, QEvent* event ) on event == QEvent::FocusOut.

                      Thanks for all.

                      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