You need to log in to create posts and topics.

CircuitView. Scroll instead of scale in case of Keyboard modifier (Ctrl/Shift) is used.

Hi all!

I've used SketchUp web for some time and really like it's scrolling approach - moving two fingers on a trackpad while Shift is pressed leads to horizontal / vertical scroll. Depending of the movement direction.

I tried to somewhat recreate this for Circuit view. In a much simplier way - no movement direction detection . Just a wheel event + Ctrl/Shift modifier for vertical / horizontal scroll. And failed). I mean it was a quick attemtpt. I don't have QT development environment set up - no QT creator or any other QT-specific tool and sadly no QT skills. I'm just using a latest dev build.
I wanted to give it a quick try using google and common sense) no luck.

void CircuitView::wheelEvent( QWheelEvent* event )
{
    //  add scroll instead of scale when Cth or Shift is pressed during wheel event
    bool noModifier = event->modifiers() == Qt::KeyboardModifier::NoModifier;
    if (m_showScroll && !noModifier){
        if (event->modifiers() == Qt::KeyboardModifier::ControlModifier){
            self()->horizontalScrollBar()->wheelEvent(event);
            return;
        }
        if (event->modifiers() == Qt::KeyboardModifier::ShiftModifier){
            self()->verticalScrollBar()->wheelEvent(event);
            return;
        }
    }
    qreal scaleFactor = pow( 2.0, event->delta() / 700.0);
    scale( scaleFactor, scaleFactor );
    m_scale *= scaleFactor;
}

But, it seems that's not how it should be done. Build results with

error: ‘virtual void QScrollBar::wheelEvent(QWheelEvent*)’ is protected within this context

So, here are the questions:
1 - is it really a quick stuff to implement?
2 - is the point of modifications selected correctly?
3 - is the selected approach overall right?

Hi.

You can pan the circuit using the middle button.
Some trackpads in laptops have an actual middle button, if not it can be emulated I think.

About your questions:
1 - Not sure, maybe you can use a similar approach to the middle button implementation.
2 - Yes, I think 2 finger events in trackpads are delivered to CircuitView::wheelEvent, but maybe not in all systems.
3 - As you can see QScrollBar::wheelEvent(QWheelEvent*) is protected. Maybe you can use QScrollBar::setValue(int)