Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Scroll bars in scroll area not coming
Forum Updated to NodeBB v4.3 + New Features

Scroll bars in scroll area not coming

Scheduled Pinned Locked Moved General and Desktop
9 Posts 3 Posters 5.9k 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
    aurora
    wrote on last edited by
    #1

    Hi all,
    Using Qt designer i created a Scroll area, and in run, dynamically adding widgets inside it...
    But unfortunately, widgets are added but scroll bar not coming...Because of this only few widgets are visible....

    I searched in forum, many r unresolved problems...
    Please help me to sort out my problem

    @
    void MainWindow::on_pushButton_clicked()
    {
    QLabel *label =new QLabel;
    label->setText("hello");
    ui->verticalLayout->addWidget(label,10);

    ui->scrollArea->widgetResizable();

    }
    @
    i set scroll bar policy as always on

    1 Reply Last reply
    0
    • P Offline
      P Offline
      p-himik
      wrote on last edited by
      #2

      If i recall correctly "this":http://developer.qt.nokia.com/doc/qt-4.8/qlayout.html#SizeConstraint-enum is what you need.

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

        I guess you didn't add a layout in the QScrollArea?

        Try adding the widgets to that layout at run time then.

        Qt Certified Specialist
        www.edalsolutions.be

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

          i added code...plz hav a look...
          i added layouts.....

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

            ya i read that,....and set it "MinAndMaxSize"
            [quote author="p-himik" date="1324972866"]If i recall correctly "this":http://developer.qt.nokia.com/doc/qt-4.8/qlayout.html#SizeConstraint-enum is what you need.[/quote]

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

              Is verticalLayout inside your scrollarea?

              This is how you can do it in Qt Designer:
              Add a QScrollArea in your form
              Add some labels inside it
              Select those labels and add a vertical layout. Remember it's name and add other labels at runtime like you did.

              Of course the QScrollArea should be in a layout too, but don't use this one. I guess that is what you do.

              Qt Certified Specialist
              www.edalsolutions.be

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

                Sorry Eddy, i tried as u told...its not working, displays same as before, scrolling not activated...:(

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

                  Can you give us your ui file to look at?

                  Qt Certified Specialist
                  www.edalsolutions.be

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

                    Ya sure Eddy.....below is my ui file code..

                    @
                    <?xml version="1.0" encoding="UTF-8"?>
                    <ui version="4.0">
                    <class>MainWindow</class>
                    <widget class="QMainWindow" name="MainWindow">
                    <property name="geometry">
                    <rect>
                    <x>0</x>
                    <y>0</y>
                    <width>734</width>
                    <height>708</height>
                    </rect>
                    </property>
                    <property name="windowTitle">
                    <string>MainWindow</string>
                    </property>
                    <widget class="QWidget" name="centralWidget">
                    <widget class="QPushButton" name="pushButton">
                    <property name="geometry">
                    <rect>
                    <x>30</x>
                    <y>150</y>
                    <width>75</width>
                    <height>23</height>
                    </rect>
                    </property>
                    <property name="text">
                    <string>PushButton</string>
                    </property>
                    </widget>
                    <widget class="QScrollArea" name="scrollArea">
                    <property name="geometry">
                    <rect>
                    <x>50</x>
                    <y>220</y>
                    <width>291</width>
                    <height>141</height>
                    </rect>
                    </property>
                    <property name="verticalScrollBarPolicy">
                    <enum>Qt::ScrollBarAlwaysOn</enum>
                    </property>
                    <property name="horizontalScrollBarPolicy">
                    <enum>Qt::ScrollBarAlwaysOn</enum>
                    </property>
                    <property name="widgetResizable">
                    <bool>true</bool>
                    </property>
                    <widget class="QWidget" name="scrollAreaWidgetContents">
                    <property name="geometry">
                    <rect>
                    <x>0</x>
                    <y>0</y>
                    <width>272</width>
                    <height>122</height>
                    </rect>
                    </property>
                    <widget class="QWidget" name="layoutWidget">
                    <property name="geometry">
                    <rect>
                    <x>30</x>
                    <y>30</y>
                    <width>24</width>
                    <height>34</height>
                    </rect>
                    </property>
                    <layout class="QVBoxLayout" name="verticalLayout">
                    <property name="sizeConstraint">
                    <enum>QLayout::SetMinAndMaxSize</enum>
                    </property>
                    <item>
                    <widget class="QLabel" name="label">
                    <property name="text">
                    <string>label</string>
                    </property>
                    </widget>
                    </item>
                    <item>
                    <widget class="QLabel" name="label_2">
                    <property name="text">
                    <string>label</string>
                    </property>
                    </widget>
                    </item>
                    </layout>
                    </widget>
                    </widget>
                    </widget>
                    <widget class="QWidget" name="verticalLayoutWidget_2">
                    <property name="geometry">
                    <rect>
                    <x>510</x>
                    <y>250</y>
                    <width>61</width>
                    <height>41</height>
                    </rect>
                    </property>
                    <layout class="QVBoxLayout" name="verticalLayout_2">
                    <property name="sizeConstraint">
                    <enum>QLayout::SetFixedSize</enum>
                    </property>
                    </layout>
                    </widget>
                    </widget>
                    <widget class="QMenuBar" name="menuBar">
                    <property name="geometry">
                    <rect>
                    <x>0</x>
                    <y>0</y>
                    <width>734</width>
                    <height>21</height>
                    </rect>
                    </property>
                    </widget>
                    <widget class="QToolBar" name="mainToolBar">
                    <attribute name="toolBarArea">
                    <enum>TopToolBarArea</enum>
                    </attribute>
                    <attribute name="toolBarBreak">
                    <bool>false</bool>
                    </attribute>
                    </widget>
                    <widget class="QStatusBar" name="statusBar"/>
                    </widget>
                    <layoutdefault spacing="6" margin="11"/>
                    <resources/>
                    <connections/>
                    </ui>
                    @

                    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