Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QEvent::Wheel working on a deactivated window.



  • I found it very weird when I saw it working.
    Here is the thing:
    Components like QComboBox, QSpinBox, etc. that accepts and changes its data through the QEvent::Wheel also changes their data when their parent window state is deactivated.

    I think this is a real bug.
    I could solve the QComboBox adding this code on eventFilter
    @bool Dialog::eventFilter(QObject *object, QEvent event)
    {
    if((QDialog
    )object)
    {
    if(event->type() == QEvent::FocusOut)
    {
    disabled = true;
    }
    else if(event->type() == QEvent::FocusIn)
    {
    disabled = false;
    }
    }

    if(object->isWidgetType() &&(event->type() == QEvent::Wheel)
    {
        if(disabled)
        {
            return true;
        }
    }
    
    return false;
    

    }@

    Unfortunately it does not work for QSpinBox, QDoubleSpinBox... it seems like they do not trigger QEvent::Wheel, so I had to connect a function to each of those components valueChanged signal, check a property I made with it's last value and reset it, in case of disable == true.

    Cayan.



  • Well, for QSpinBox and QDoubleSpinBox, it is the QLineEdit instead of Q..SpinBox receive the Wheel event.



  • Well, I subclasses both of those, made a function to return the pointer for their lineEdit and installed the event filter, still not working =[

    I'm about to sleep, I'll study more regarding these QLineEdits tomorrow.

    Thanks anyway


Log in to reply