[Qt-interest] QComboBox Popup Access

Sean Hayes sean.t.hayes at Vanderbilt.Edu
Wed Oct 13 04:43:18 CEST 2010


I am trying to get a QComboBox derivative to work with a QGesture
rather than mouse events. To do this I will use on gesture to open
show the popup and another to select an item. To do this, I need
access to the events that normally get taken up by the popup. Is there
a way to get access to the popup and apply a event filter to it? I see
that it is a QComboBoxPrivateContainer and I do not have any access to
it. However, it seems that there should be a way to get access to any
events associated with the QComboBox. Below is my attempt to access
the container. Unfortunately, I need access to the popup before the
first hidePopup() call. Is there a way to prevent the popup from
taking all the events when it is open?

Thanks for the help!

void MyComboBox::hidePopup() {
    // Trick Qt into giving use the pointer to this QComboBox's popup
    if(m_pQComboBoxPrivateContainer == NULL) {
         QWidget* popupWidget = QApplication::activePopupWidget();
         if(popupWidget != NULL && ParentLocalSwipeContainer() != NULL) {
              m_pQComboBoxPrivateContainer = popupWidget;

              // Install an event filter on it so events can be
received while the popup is open
              m_pQComboBoxPrivateContainer->installEventFilter(this);
              m_pQComboBoxPrivateContainer->grabGesture(MyGestureType);
         }
    }
    // Parent function purposely not called (do not want it to close yet).
}



More information about the Qt-interest-old mailing list