How to make QQuickView scrollable?



  • Hello,

    I add a QQuickView instance to QWidget and want to add a scrollbar, too. So I could have a large area of QQuickView in a smaller widget, where I could scrolling. But I does not really know, how I can make it. I try it with ScrollArea, but this is not successful:

    @
    QQuickView *view = new QQuickView(this);
    view.setMinimumSize(1600, 1000);

    QScrollArea *area = new QScrollArea(this);
    QWidget container = new QWidget(qobject_cast<QWidget>(area));
    container->setMinimumSize(view->minimumWidth(), view->minimumHeight());
    area->setWidget(container->createWindowContainer(view, container->parentWidget()));
    area->setWidgetResizable(true);
    area->setMinimumSize(600, 500);
    area->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
    area->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
    @

    Hopefully, anyone can help me?



  • I haven't tried what you are attempting, but I would recommend to put the scrollbars inside the QtQuick code by using a ScrollView from QtQuick.Controls.

    This would save quite a bit of resources since the framebuffer of the QQuickView will be limited to what is shown on screen.

    You can have arbitrarily large ScrollView this way, but with your approach you will be limited by the maximum size of an OpenGL window.



  • Ok, thank you for answer. Meanwhile I decide to use QGraphicsScene and set QQuickView aside, in spite of advantages like QML 2.0.

    I set this thread not as solved, in case somebody else still searching another answer to this question or somebody else knows another answer, too.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.