Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. [Solved] Scroll Area
Forum Updated to NodeBB v4.3 + New Features

[Solved] Scroll Area

Scheduled Pinned Locked Moved Mobile and Embedded
15 Posts 3 Posters 10.1k Views 1 Watching
  • 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.
  • A Offline
    A Offline
    alfah
    wrote on last edited by
    #1

    can i put a layout into a scroll area. cuz when i did tht i could get any scroll bars. I have a series of labels put into layouts. I have tried to put the layout into the scrollarea.

    It doesn work. Any other alternative?? Shouldi put the labels directly on to the scroll area

    Thanks

    alfah

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      Yes, but you need to put the layout on QScrollArea::widget(), not on the QScrollArea itself.

      1 Reply Last reply
      0
      • A Offline
        A Offline
        alfah
        wrote on last edited by
        #3

        andre

        @
        QScrollArea *scrollarea = new QScrollArea();

        controlLayout=new QVBoxLayout;
        controlLayoutSec=new QVBoxLayout;
        controlLayout->addWidget(lblBlnk);
        controlLayoutSec->addWidget(lblBlnk);
        
        
        
        hLayout3->addLayout(controlLayout);
        hLayout3->addSpacing(50);
        hLayout3->addLayout(controlLayoutSec);
        
        scrollarea->setWidget(hLayout3);
        

        @

        I have done somethin like tht but the scrol bars do not appear

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andre
          wrote on last edited by
          #4

          hLayout3 is not a widget, but a layout. Instead, do something like this:

          @
          scrollArea->widget()->setLayout(hLayout3);
          @

          1 Reply Last reply
          0
          • A Offline
            A Offline
            alfah
            wrote on last edited by
            #5

            andre

            the following line jus aborted prograrm
            @
            scrollarea->widget()->setLayout(hLayout3);
            @

            is it addwidget???

            1 Reply Last reply
            0
            • A Offline
              A Offline
              andre
              wrote on last edited by
              #6

              Perhaps widget() returns 0, and you need to create such a widget first yourself.
              Try:
              @
              QWidget* baseArea = new QWidget(0);
              baseArea->setLayout(hLayout3);
              scrollArea->setWidget(baseArea);
              @

              1 Reply Last reply
              0
              • A Offline
                A Offline
                alfah
                wrote on last edited by
                #7

                I have written the following two lines too
                @

                QHBoxLayout *hLayoutScrollArea = new QHBoxLayout;
                hLayoutScrollArea->addWidget(scrollarea);

                @

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  andre
                  wrote on last edited by
                  #8

                  That will put the scroll area itself in a layout, but without something like this, will not do anything:

                  @
                  theParentWidgetOfYourScrollArea->setLayout(hLayoutScrollArea);
                  @

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    alfah
                    wrote on last edited by
                    #9

                    i got the program runnin but no widgets are displayed!!!!
                    @
                    QHBoxLayout *hLayout3 = new QHBoxLayout;
                    QLabel *lblBlnk =new QLabel();

                    QScrollArea *scrollarea =  new QScrollArea();
                    
                    
                    controlLayout=new QVBoxLayout;
                    controlLayoutSec=new QVBoxLayout;
                    controlLayout->addWidget(lblBlnk);
                    controlLayoutSec->addWidget(lblBlnk);
                    
                    
                    
                    hLayout3->addLayout(controlLayout);
                    hLayout3->addSpacing(50);
                    hLayout3->addLayout(controlLayoutSec);
                    
                    QWidget *baseArea = new QWidget();
                    baseArea->setLayout(hLayout3);
                    scrollarea->setWidget(baseArea);
                    
                    
                    scrollarea->widget()->setLayout(hLayout3);
                    
                    
                    QHBoxLayout *hLayoutScrollArea = new QHBoxLayout;
                    hLayoutScrollArea->addWidget(scrollarea);
                    
                    
                    secondLbl =new QLabel();
                    secondLbl->setText(" ");
                    
                    vLayout=new QVBoxLayout;
                    vLayout->addWidget(lblHeader);
                    vLayout->addSpacing(50);
                    vLayout->addLayout(hLayout1);
                    vLayout->addWidget(lblTitle2);
                    vLayout->addLayout(hLayout2);
                    vLayout->addLayout(hLayoutScrollArea);
                    vLayout->addWidget(secondLbl);
                    

                    @

                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      alfah
                      wrote on last edited by
                      #10

                      Found tht something is displayed, but its not legible.

                      I have put the scroll area into another layout. and finally all the layouts are put into one single vLayout.
                      I have done this so as to display in another class containing tabs, so the final vLayout goes into the another widget and then displayed on tabs

                      1 Reply Last reply
                      0
                      • A Offline
                        A Offline
                        andre
                        wrote on last edited by
                        #11

                        Make sure that the top level layout (there can be only one!) is actually set on the top level widget. Otherwise, your dialog will not properly layout at all.

                        1 Reply Last reply
                        0
                        • A Offline
                          A Offline
                          alfah
                          wrote on last edited by
                          #12

                          the thing is, every other widget in the form, other than the scrollares is displayed. Its the jus the scrollarea which is messed up

                          1 Reply Last reply
                          0
                          • A Offline
                            A Offline
                            alfah
                            wrote on last edited by
                            #13

                            could u tell me how to include an image, i'l show a diagram to explain better what im tryin to do

                            1 Reply Last reply
                            0
                            • EddyE Offline
                              EddyE Offline
                              Eddy
                              wrote on last edited by
                              #14

                              "Forum help":http://developer.qt.nokia.com/wiki/ForumHelp#9bd9c32b79efb1b2d5b039e4d48300a9

                              Qt Certified Specialist
                              www.edalsolutions.be

                              1 Reply Last reply
                              0
                              • A Offline
                                A Offline
                                alfah
                                wrote on last edited by
                                #15

                                :D i got it right. It was jus that the widgets were not stretched. There is a property called setWidgetResizable(true) which automatically adjusts the size of widgets. :)

                                solution:
                                after you create a scroll area jus add the following line
                                @
                                scrollarea->setWidgetResizable(true);
                                @

                                Au Revoir :D

                                alfah

                                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