Results 1 to 6 of 6

Thread: adding items in scroll area dynamically

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2009
    Posts
    2
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: adding items in scroll area dynamically

    Hi,

    Thanks for the reply. Pls find the code below for your reference.


    This is the code for my scroll area in my mainwindow..

    Qt Code:
    1. scrollArea = new QScrollArea(centralwidget);
    2. scrollArea->setObjectName(QString::fromUtf8("scrollArea"));
    3. scrollArea->setGeometry(QRect(1050, 168, 208, 684));
    4. QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    5. sizePolicy.setHorizontalStretch(0);
    6. sizePolicy.setVerticalStretch(0);
    7. scrollArea->setSizePolicy(sizePolicy);
    8. scrollArea->setStyleSheet(QString::fromUtf8("background-color: rgb(255, 255, 255);"));
    9. scrollArea->setFrameShadow(QFrame::Sunken);
    10. scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
    11. scrollArea->setWidgetResizable(true);
    12. scrollArea->setAlignment(Qt::AlignJustify|Qt::AlignTop);
    13. scrollAreaWidgetContents = new QWidget();
    14. scrollAreaWidgetContents->setObjectName(QString::fromUtf8("scrollAreaWidgetContents"));
    15. scrollAreaWidgetContents->setGeometry(QRect(0, 0, 206, 682));
    16.  
    17. Code for placing groupbox in scrollarea..
    18.  
    19. void mainwindow::creatDatabaseBox()
    20. {
    21. static int cCnt = 0;
    22. static int yAxis = 30;
    23. ++cCnt;
    24.  
    25. databaseGrpBox = new QGroupBox(ui.scrollAreaWidgetContents);
    26. databaseGrpBox->setObjectName(QString("dataBaseGrpBox%1").arg(cCnt));
    27. databaseGrpBox->setGeometry(QRect(10,yAxis,174,50));
    28. databaseGrpBox->setTitle("QString("dataBaseGrpBox%1").arg(cCnt)");
    29.  
    30. yAxis = YAxis+55;
    31. }
    To copy to clipboard, switch view to plain text mode 
    This will be called when a connection button is pressed..
    Last edited by jpn; 22nd May 2009 at 16:36. Reason: missing [code] tags

  2. #2
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    4
    Thanked 140 Times in 132 Posts

    Default Re: adding items in scroll area dynamically

    pls edit your post and add [ CODE ] tags :]
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

  3. #3
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    4
    Thanked 140 Times in 132 Posts

    Default Re: adding items in scroll area dynamically

    ok, and I see you have to use layouts :]
    Just add the QVBoxLayout to your scroll area and place widgets in it.
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

Similar Threads

  1. Replies: 5
    Last Post: 17th February 2009, 04:35
  2. abstract scroll area
    By moowy in forum Qt Programming
    Replies: 2
    Last Post: 2nd October 2006, 09:15
  3. Dynamically adding tabs
    By larry104 in forum Qt Programming
    Replies: 7
    Last Post: 26th July 2006, 20:27
  4. [Qt4]: Adding centered items in QListWidget
    By Jojo in forum Qt Programming
    Replies: 4
    Last Post: 16th March 2006, 20:04
  5. QRubberBand painting in the scroll area widget
    By SkripT in forum Qt Programming
    Replies: 7
    Last Post: 17th January 2006, 16:48

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
  •  
Qt is a trademark of The Qt Company.