Results 1 to 2 of 2

Thread: Scrolling bar problem in QScrollArea

  1. #1
    Join Date
    Apr 2006
    Location
    Saint-Petersburg, Russia
    Posts
    63
    Thanks
    15
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Scrolling bar problem in QScrollArea

    Hello !

    I have some widgets in horizontal layout, this layout was put in vertical layout and vertical layout was put in QScrollArea item.

    Qt Code:
    1. QScrollArea * searchAttrs = new QScrollArea (gbAttr);
    2.  
    3. QGridLayout *gLayout = new QGridLayout (this);
    4. gLayout->addWidget (searchAttrs);
    5. QVBoxLayout * vBLayout = new QVBoxLayout (searchAttrs);
    6. vBLayout->setSpacing(6);
    7. vBLayout->setMargin(0);
    8. vBLayout->setObjectName(QString::fromUtf8("vBLayout"));
    9. int num = 1;
    10. QHBoxLayout *hBLayout = new QHBoxLayout();
    11. hBLayout->setSpacing(6);
    12. hBLayout->setMargin(0);
    13. QComboBox *cbsAttrName = new QComboBox (searchAttrs);//gbAttr);
    14. cbsAttrName->setEditable(true);
    15. cbsAttrName->setObjectName (QString("cbsAttrName%1").arg(num));
    16.  
    17. cbsAttrName->setVisible (true);
    18. this->cbsAttrNames.append (cbsAttrName);
    19.  
    20. hBLayout->addWidget (cbsAttrName);
    21.  
    22. QComboBox * cbsAttrRel = new QComboBox (searchAttrs);//gbAttr);
    23. this->cbsAttrRels.append (cbsAttrRel);
    24. cbsAttrRel->setObjectName (QString("cbsAttrRel%1").arg(num));
    25.  
    26. cbsAttrRel->setVisible (true);
    27.  
    28. hBLayout->addWidget (cbsAttrRel);
    29.  
    30. QLineEdit *sLEValue = new QLineEdit (searchAttrs);//gbAttr);
    31. sLEValue->setObjectName (QString("sLEValue%1").arg(num));
    32.  
    33. sLEValue->setVisible (true);
    34. this->leVals.append (sLEValue);
    35.  
    36. hBLayout->addWidget (sLEValue);
    37.  
    38. QToolButton *sTBMore = new QToolButton (searchAttrs);//gbAttr);
    39. sTBMore->setObjectName(QString::fromUtf8("sTBMore%1").arg(num));
    40. sTBMore->setText (QString::fromUtf8("+"));
    41.  
    42. sTBMore->setVisible (true);
    43. this->stbMore.append (sTBMore);
    44.  
    45. hBLayout->addWidget (sTBMore);
    46.  
    47. QToolButton *sTBFewer = new QToolButton(searchAttrs);//gbAttr);
    48. sTBFewer->setObjectName(QString::fromUtf8("sTBFewer%1").arg(num));
    49. sTBFewer->setText (QString::fromUtf8("-"));
    50.  
    51. sTBFewer->setVisible (true);
    52. this->stbFewer.append (sTBFewer);
    53.  
    54. hBLayout->addWidget (sTBFewer);
    55.  
    56. if (num==0)
    57. vBLayout->addLayout (hBLayout);//, vBLayout->count()-1);
    58. else
    59. vBLayout->insertLayout (vBLayout->count()-1, hBLayout);
    60. connect (sTBMore, SIGNAL(pressed()), this, SLOT (addAttr()) );
    61. connect (sTBFewer, SIGNAL(pressed()), this, SLOT (delAttr ()) );
    62.  
    63. spacerItem = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
    64.  
    65. vBLayout->addItem (spacerItem);
    66. searchAttrs->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Expanding);
    To copy to clipboard, switch view to plain text mode 

    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 ?
    Last edited by e8johan; 29th January 2007 at 11:49. Reason: missing [code] tags
    Best regards,
    Yuriy Rusinov.

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Scrolling bar problem in QScrollArea

    Don't install a layout on the QScrollArea widget. Use QScrollArea::setWidget() to set a widget inside the scroll area.
    J-P Nurmi

Similar Threads

  1. QTreeView problem scrolling to end.
    By seneca in forum Qt Programming
    Replies: 7
    Last Post: 22nd December 2015, 13:08
  2. Replies: 2
    Last Post: 8th October 2006, 21:14
  3. Replies: 16
    Last Post: 7th March 2006, 16:57
  4. QScrollArea problem positioning a QWidget inside
    By Spectator in forum Qt Programming
    Replies: 4
    Last Post: 20th February 2006, 23:59
  5. Problem with QScrollArea updating from 4.0.1 to 4.1.0
    By SkripT in forum Qt Programming
    Replies: 8
    Last Post: 28th January 2006, 23:35

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.