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

Finding gap in layouts after adding scrollarea to the dock widget



  • Hi,

    I am trying to set scroll area to the dock widget, which has a vertical layout which gets filled dynamically with custom collapsible group box , when i add two or more collapsible groups i m getting gap between 1st and next collapsible group box .
    i have done setspacing = 0 for layout ;

    Note - it was working fine before i add scroll area .
    before it was something like this without scroll area-
    0_1557834322044_Capture1.PNG

    After adding this code in respective .Cpp
    QScrollArea* scrollArea = new QScrollArea(this);
    scrollArea->setGeometry(10, 10, 390, 800);
    scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
    scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
    scrollArea->setWidgetResizable(true);
    scrollArea->setWidget(ui->dockWidget);

    0_1557833801436_Capture.PNG

    can anyone suggest me what could be the problem.


  • Lifetime Qt Champion

    hi
    i dont see any
    pLayout->setContentsMargins(0,0,0,0);



  • i have set pLayout->setContentsMargins(0,0,0,0); still i cannot see any changes, same problem occurs.


  • Lifetime Qt Champion

    Ok.
    Since it also seems the TextEdit have space around it , im out of guesses.

    Are you sure you setContentsMargins on the right layout ?
    Did you try to raise the values and see space would become bigger ?



  • Yes i am setting to the right layout,
    after setting ui->pLayout->setContentsMargins(20,20,20,20); it effected left right top bottom, not the gap between two layouts it is happening only after adding scroll area ..

    0_1557913872355_Capture2_LI.jpg

    Also after adding ui->verticalLayout->setContentsMargins(20,20,20,20); to the inside layout results are like this:
    0_1557914571781_Capture3_LI.jpg
    if i close all :
    1_1557914571781_Capture4_LI.jpg !


  • Lifetime Qt Champion

    Hi
    Looks like its that collapse thing that does it.
    when open, there is no space between them.
    in any case, i have no more guesses.
    I would try with plain QFrames and see.



  • This has been resolved by using QToolbox instead of custom widget
    Thank you


Log in to reply