I'm trying to implement a custom scrolling behavior in a QTextEdit control. It seems to be working but I'm having problems with the PageDown/PageUp key press: I'm controlling the scrolling behavior through the actionTriggered signal since the documentation states:
When the signal is emitted, the sliderPosition has been adjusted according to the action, but the value has not yet been propagated (meaning the valueChanged() signal was not yet emitted), and the visual display has not been updated. In slots connected to this signal you can thus safely adjust any action by calling setSliderPosition() yourself, based on both the action and the slider's value.
and starting a QTimer with the sliderPosition
I need to reach from there (e.g. I'm incrementing each time value()
to reach sliderPosition
). Unfortunately every time I press a PageUp/PageDown key there's also another setValue() function call triggered by the caret which gets moved by the PageUp/PageDown key which moves automatically the scrollbar value to the end of the animation.
The call stack shows:
QAbstractSlider::setValue(int)
??
QMetaObject::activate(QObject*, int, int, void**)
QWidgetTextControl::visibilityRequest(QRectF const&)
QWidgetTextControl::ensureCursorVisible() <--
QWidgetTextControl::setTextCursor(QTextCursor const&) <--
QTextEdit::keyPressEvent(QKeyEvent*)
QWidget::event(QEvent*)
QFrame::event(QEvent*)
QAbstractScrollArea::event(QEvent*)
QTextEdit::event(QEvent*)
QApplicationPrivate::notify_helper(QObject*, QEvent*)
QApplication::notify(QObject*, QEvent*)
QCoreApplication::notifyInternal(QObject*, QEvent*)
...
I have no idea of how to prevent the caret from issuing that QAbstractSlider::SetValue()
call when the caret is moved due to the PageUp/PageDown key press.
Any help would be highly appreciated.
OKay, so just use
disconnect(receiver, SLOT(setValue...), unwanted_sender, SIGNAL(...))
to break the specific unwanted connection.