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. drop down > ?

drop down > ?

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 3 Posters 282 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.
  • D Offline
    D Offline
    Duy Khang
    wrote on last edited by
    #1

    how can i auto drop down comboBox when mouse hover into it ?

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by mrjj
      #2

      Hi
      well you can subclass it and overwrite the enter event and then call
      https://doc.qt.io/qt-5/qcombobox.html#showPopup
      or use an event filer to look for enter and do the same.

      sorry its
      void QWidget::enterEvent(QEvent *event)
      void QWidget::leaveEvent(QEvent *event)

      D 1 Reply Last reply
      2
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        You can use showPopup to force the drop down to show.

        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
        • mrjjM mrjj

          Hi
          well you can subclass it and overwrite the enter event and then call
          https://doc.qt.io/qt-5/qcombobox.html#showPopup
          or use an event filer to look for enter and do the same.

          sorry its
          void QWidget::enterEvent(QEvent *event)
          void QWidget::leaveEvent(QEvent *event)

          D Offline
          D Offline
          Duy Khang
          wrote on last edited by
          #4

          @mrjj just mouse hover not enterEvent

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

            You can use the QMouseHoverEvent.

            See the class details on how to enable it.

            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
            1
            • D Duy Khang

              @mrjj just mouse hover not enterEvent

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by mrjj
              #6

              @Duy-Khang
              Yes You are right. enterEvent is a bit too aggressive :)
              alt text

              Update:
              HoverEvent is less fast. but not as much as i expected.

              class combo : public QComboBox
              {
              public:
                  explicit  combo(QWidget *parent ) : QComboBox(parent)
                  {
                      setAttribute(Qt::WA_Hover);
                  }
              
              protected:
              
                  virtual bool event(QEvent *event) override
                  {
                      switch (event->type()) {
                      case QEvent::HoverEnter:
                          if ( ! view()->isVisible() ) {
                              showPopup();
                          }
                          return true;
                          break;
                      case QEvent::HoverLeave:
                          return true;
                          break;
                      case QEvent::HoverMove:
                          return true;
                          break;
                      default:
                          break;
                      }
                      return QComboBox::event(event);
                  }
              };
              
              1 Reply Last reply
              1

              • Login

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