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. Can not debug my custom widget by using break point
Qt 6.11 is out! See what's new in the release blog

Can not debug my custom widget by using break point

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 3 Posters 1.8k 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.
  • 8 Offline
    8 Offline
    86926891
    wrote on last edited by
    #1

    I create a widget which was inherited from QComboBox, and I re-write the hidePopup() to let my widget would not hide popup when a item was clicked( to support multi select ).
    It works, but when I use break point to debug my program, if we get to the break point when my custom widget's popup was not hide, everything seems froze, I can not control anything with the popup always on the top. The only thing I can do is reboot my computer by long pressing my power key.
    I don't know what happened, but it seems the popup of my widget catch the keyboard focus(I guess)
    If I remove my re-write hidePopup(), the break point works well.
    Anyone can help me?

    jsulmJ 1 Reply Last reply
    0
    • 8 86926891

      I create a widget which was inherited from QComboBox, and I re-write the hidePopup() to let my widget would not hide popup when a item was clicked( to support multi select ).
      It works, but when I use break point to debug my program, if we get to the break point when my custom widget's popup was not hide, everything seems froze, I can not control anything with the popup always on the top. The only thing I can do is reboot my computer by long pressing my power key.
      I don't know what happened, but it seems the popup of my widget catch the keyboard focus(I guess)
      If I remove my re-write hidePopup(), the break point works well.
      Anyone can help me?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @86926891 You app is simply paused as long as it is waiting at the breakpoint, just press F5 to continue from the break point...

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      8 1 Reply Last reply
      0
      • jsulmJ jsulm

        @86926891 You app is simply paused as long as it is waiting at the breakpoint, just press F5 to continue from the break point...

        8 Offline
        8 Offline
        86926891
        wrote on last edited by
        #3

        @jsulm I know that, but F5, F10 & F11 do not works with the popup always on the top( even on the top of Qt Creator)

        jsulmJ 1 Reply Last reply
        0
        • 8 86926891

          @jsulm I know that, but F5, F10 & F11 do not works with the popup always on the top( even on the top of Qt Creator)

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @86926891 What are you doing in hidePopup()?

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          8 2 Replies Last reply
          0
          • jsulmJ jsulm

            @86926891 What are you doing in hidePopup()?

            8 Offline
            8 Offline
            86926891
            wrote on last edited by
            #5

            @jsulm This is how I re-write the hidePopup:
            void hidePopup()
            {
            int width = this->width();
            int height = mListWidget->height();
            int x = QCursor::pos().x() - mapToGlobal(geometry().topLeft()).x() + geometry().x();
            int y = QCursor::pos().y() - mapToGlobal(geometry().topLeft()).y() + geometry().y();
            if (x >= 0 && x <= width && y >= this->height() && y <= height + this->height())
            {
            // Item was clicked, do not hide popup
            }
            else
            {
            QComboBox::hidePopup();
            }
            }

            The purpose of re-writing hidePopup() is to avoid the popup was hided when I click an item of my combobox

            JonBJ 1 Reply Last reply
            0
            • jsulmJ jsulm

              @86926891 What are you doing in hidePopup()?

              8 Offline
              8 Offline
              86926891
              wrote on last edited by
              #6

              @jsulm So I get to my break point, the popup was not hid

              1 Reply Last reply
              0
              • 8 86926891

                @jsulm This is how I re-write the hidePopup:
                void hidePopup()
                {
                int width = this->width();
                int height = mListWidget->height();
                int x = QCursor::pos().x() - mapToGlobal(geometry().topLeft()).x() + geometry().x();
                int y = QCursor::pos().y() - mapToGlobal(geometry().topLeft()).y() + geometry().y();
                if (x >= 0 && x <= width && y >= this->height() && y <= height + this->height())
                {
                // Item was clicked, do not hide popup
                }
                else
                {
                QComboBox::hidePopup();
                }
                }

                The purpose of re-writing hidePopup() is to avoid the popup was hided when I click an item of my combobox

                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on last edited by JonB
                #7

                @86926891
                I don't know your exact situation, but:

                • You are suppressing the fundamental ability to hide/dismiss the popup (when for whatever reason the if route of your code is followed). This may interfere with the basic working of a combobox, which might make things go nasty as you describe. Windows does a funny thing with the dropdown list of a combobox when it is displayed, making it a detached window which lies on top of everything; quite possibly it has grabbed keyboard focus too, basically Windows is waiting for that popup to disappear before anything else. Even native debuggers have a problem whereby if you hit a breakpoint when it is displayed you are stuck with the dropdown visible on top of everything else, which does not disappear till the popup gets closed, sometimes making debugging a bit awkward.

                • QComboBox/native combobox is an inherently single-select widget/control. Trying to make it multiselect sounds quite wrong to me. Use a QListWidget or something.

                1 Reply Last reply
                2

                • Login

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