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

Scroll area not scrolling



  • On the UI side, using QtCreator, I have a QScrollArea and I use this code to put a widget in it.

    void ServiceAppLayout::setSideBarWidget(QWidget *widget)
    {
        ui->sideBarScrollArea->setWidget(widget);
    }
    

    This works fine, as the widget appears as expected, but if the widget is oversized, the scroll area doesn't offer scroll bars. What am I missing? How do I get the scroll bars to appear when needed?


  • Qt Champions 2017

    which platform ? Did you try with simple example like follows ? Does it work ?

    MainWindow w;
    w.resize(600,600);
    
    QScrollArea area;
    area.setWidget(&w);
    area.show();


  • Ok, I figured it out, it had nothing to do with my code, or the scroll area. The widget that is handed to the scroll area has to have a layout defined, and all the visual elements need to be in that layout. This I discovered by accident this morning.


Log in to reply