Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 5

Qt-interest Archive, January 2007
Scrolling bar problem in QScrollArea


Message 1 in thread

Hello !

I have some widgets in horizontal layout, this layout was put in vertical
layout and vertical layout was put in QScrollArea item.
    QScrollArea * searchAttrs = new QScrollArea (gbAttr);

    QGridLayout *gLayout = new QGridLayout (this);
    gLayout->addWidget (searchAttrs);
    QVBoxLayout * vBLayout = new QVBoxLayout (searchAttrs);
    vBLayout->setSpacing(6);
    vBLayout->setMargin(0);
    vBLayout->setObjectName(QString::fromUtf8("vBLayout"));
    int num = 1;
    QHBoxLayout *hBLayout = new QHBoxLayout();
    hBLayout->setSpacing(6);
    hBLayout->setMargin(0);
    QComboBox *cbsAttrName = new QComboBox (searchAttrs);//gbAttr);
    cbsAttrName->setEditable(true);
    cbsAttrName->setObjectName (QString("cbsAttrName%1").arg(num));

    cbsAttrName->setVisible (true);
    this->cbsAttrNames.append (cbsAttrName);

    hBLayout->addWidget (cbsAttrName);

    QComboBox * cbsAttrRel = new QComboBox (searchAttrs);//gbAttr);
    this->cbsAttrRels.append (cbsAttrRel);
    cbsAttrRel->setObjectName (QString("cbsAttrRel%1").arg(num));

    cbsAttrRel->setVisible (true);

    hBLayout->addWidget (cbsAttrRel);

    QLineEdit *sLEValue = new QLineEdit (searchAttrs);//gbAttr);
    sLEValue->setObjectName (QString("sLEValue%1").arg(num));

    sLEValue->setVisible (true);
    this->leVals.append (sLEValue);

    hBLayout->addWidget (sLEValue);

    QToolButton *sTBMore = new QToolButton (searchAttrs);//gbAttr);
    sTBMore->setObjectName(QString::fromUtf8("sTBMore%1").arg(num));
    sTBMore->setText (QString::fromUtf8("+"));

    sTBMore->setVisible (true);
    this->stbMore.append (sTBMore);

    hBLayout->addWidget (sTBMore);

    QToolButton *sTBFewer = new QToolButton(searchAttrs);//gbAttr);
    sTBFewer->setObjectName(QString::fromUtf8("sTBFewer%1").arg(num));
    sTBFewer->setText (QString::fromUtf8("-"));

    sTBFewer->setVisible (true);
    this->stbFewer.append (sTBFewer);

    hBLayout->addWidget (sTBFewer);

    if (num==0)
        vBLayout->addLayout (hBLayout);//, vBLayout->count()-1);
    else
        vBLayout->insertLayout (vBLayout->count()-1, hBLayout);
    connect (sTBMore, SIGNAL(pressed()), this, SLOT (addAttr()) );
    connect (sTBFewer, SIGNAL(pressed()), this, SLOT (delAttr ()) );

    spacerItem = new QSpacerItem(20, 40, QSizePolicy::Minimum,
QSizePolicy::Expanding);

    vBLayout->addItem (spacerItem);
    searchAttrs->setSizePolicy (QSizePolicy::Expanding,
QSizePolicy::Expanding);

If I press sTBMore toolbutton too many times then hBLayout height is
decreasing, but vertical scroll bar in searchAttrs does not appear. Which
way I have to make hBLayout fixed height and make scrolling in QScrollArea ?

-- 
 [ signature omitted ]