Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QScrollArea nested layouts

QScrollArea nested layouts

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 602 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    guy incognito
    wrote on last edited by guy incognito
    #1

    Hi all,

    I got some problems with the QScrollArea. Following code creates a Qt3DWindow in a windowContainer.
    This container is embedded in a QHBoxLayout along with a QVBoxLayout which contains several other widgets (like buttons).
    For the case that the QVBoxLayout gets stuffed with too many widget I would like to make i scrollable but my approaches were not satisfying.

    original code which works fine (without scrolling):

    QWidget* container = QWidget::createWindowContainer(view); // view => Window3D
    QSize screenSize = view->screen()->size();
    container->setMinimumSize(QSize(200, 100));
    container->setMaximumSize(screenSize);
    
    QWidget* widget = new QWidget;
    QHBoxLayout* hLayout = new QHBoxLayout(widget);
    QVBoxLayout* vLayout = new QVBoxLayout;
    
    vLayout->setAlignment(Qt::AlignTop);
    hLayout->addWidget(container, 1);
    hLayout->addLayout(vLayout);
    

    scolling approach:

    QWidget* widget = new QWidget;
    QHBoxLayout* hLayout = new QHBoxLayout(widget);
    
    QWidget* widget2 = new QWidget;
    QVBoxLayout* vLayout = new QVBoxLayout(widget2);
    
    vLayout->setAlignment(Qt::AlignTop);
    hLayout->addWidget(container, 1);
    hLayout->addWidget(widget2);
    
    QScrollArea* area = new QScrollArea;
    area->setWidget(widget); // whole layout is scrollable
    //area->setWidget(widget2); // only vLayout is displayed (and scrollable)
    area->setWidgetResizable(true);
    

    Edit:
    This is from the Qt3D example "basicshapes". I want to make the verticalLayout at the right scrollable while the 3D view container stays the same size. The original code from above belongs to this.

    0_1501494163338_Unbenannt.PNG

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved