Qt : QWheelEvent does not refer to a value -
Qt : QWheelEvent does not refer to a value -
i'm trying create ctrl + mousewheel macro zoom in , out of image view in application.
currently trying utilize current code:
new qshortcut(qkeysequence(qt::ctrl + qwidget::wheelevent(qwheelevent *event)), this, slot(zoom())); however error qwheelevent not refer value. have necessary includes in header file not understand why i'm getting error.
is illegal bind widget event in conjunction within qkeysequence? if so, how should handle event?
you can't utilize qkeysequence in way. should reimplement wheelevent or utilize next event filter (it illustration how zoom in/out in textedit, can utilize code special case):
bool mainwindow::eventfilter(qobject *obj, qevent *event) { if(obj == ui->plaintextedit && event->type() == qevent::wheel ) { qwheelevent *wheel = static_cast<qwheelevent*>(event); if( wheel->modifiers() == qt::controlmodifier ) if(wheel->delta() > 0) ui->plaintextedit->zoomin(2); else ui->plaintextedit->zoomout(2); } homecoming qobject::eventfilter(obj, event); } main idea: grab wheel event , check ctrl modifier pressed.
to utilize eventfilter should also:
protected: bool eventfilter(qobject *obj, qevent *event);//in header and
qapp->installeventfilter(this);//in constructor note: showed illustration event filter because not require subclassing, not improve or else, reimplement wheelevent similar code , absolutely same result.
qt
Comments
Post a Comment