Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. QT Designer Scroll Area not working as expected.

QT Designer Scroll Area not working as expected.

Scheduled Pinned Locked Moved Qt Creator and other tools
7 Posts 3 Posters 14.8k Views
  • 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.
  • R Offline
    R Offline
    redace
    wrote on 19 Jul 2010, 13:14 last edited by
    #1

    Hello all!

    I am an Autodesk maya 2011 user and I am trying to create a UI in QT with a Scroll Area in it.
    However so far I have not been able to get it working. I searched a lot for this problem but so far I have not found anyone with a similar problem.
    I also checked the help file on this problem but the scroll area topic in the help file only focuses on using scroll area's within code.
    As far as I know I can not use any form of scripting/code except for the script in the UI file itself since Autodesk Maya only reads the UI file. Other than that I am a complete novice using QT. :)

    Problem:

    When I create a Scroll Area in a mainWindow and place any layout or widget inside of it that is larger than the Scroll Area the Scroll area does not show any Scroll bars. Even if I set the verticalScrollBarPolicy to alwaysOn then it only shows a grayed out scrollbar.
    In QT aswell as in maya (ofcourse)

    Do I need to do anything extra in order to make the Scroll Area work.

    Any help or suggestions would be most appreciated.

    Thanks!!

    Red

    1 Reply Last reply
    0
    • K Offline
      K Offline
      kkoehne
      Moderators
      wrote on 20 Jul 2010, 07:51 last edited by
      #2

      Hi, I cannot reproduce your problem. Here is an example file I created:

      @<?xml version="1.0" encoding="UTF-8"?>
      <ui version="4.0">
      <class>Form</class>
      <widget class="QWidget" name="Form">
      <property name="geometry">
      <rect>
      <x>0</x>
      <y>0</y>
      <width>400</width>
      <height>300</height>
      </rect>
      </property>
      <property name="windowTitle">
      <string>Form</string>
      </property>
      <layout class="QGridLayout" name="gridLayout">
      <item row="0" column="0">
      <widget class="QScrollArea" name="scrollArea">
      <property name="widgetResizable">
      <bool>true</bool>
      </property>
      <widget class="QWidget" name="scrollAreaWidgetContents">
      <property name="geometry">
      <rect>
      <x>0</x>
      <y>0</y>
      <width>96</width>
      <height>26</height>
      </rect>
      </property>
      <widget class="QListView" name="listView">
      <property name="geometry">
      <rect>
      <x>0</x>
      <y>0</y>
      <width>300</width>
      <height>300</height>
      </rect>
      </property>
      <property name="minimumSize">
      <size>
      <width>300</width>
      <height>300</height>
      </size>
      </property>
      </widget>
      </widget>
      </widget>
      </item>
      </layout>
      </widget>
      <resources/>
      <connections/>
      </ui>@

      Scrollareas show up nicely on demand for me.

      Director R&D, The Qt Company

      1 Reply Last reply
      0
      • R Offline
        R Offline
        redace
        wrote on 20 Jul 2010, 11:40 last edited by
        #3

        Hey,

        thank you for your explanation.

        I have tried to open the file you created as UI file but then QT gives an error.

        Cannot open file: (file path)

        I am now trying to reproduce your code to see if that will work.

        1 Reply Last reply
        0
        • K Offline
          K Offline
          kkoehne
          Moderators
          wrote on 20 Jul 2010, 11:54 last edited by
          #4

          Actually the forum decided to 'cryptify' the qml file posted ... Just remove the very first line (xml version="1.0" etc), it should then load fine.

          Director R&D, The Qt Company

          1 Reply Last reply
          0
          • R Offline
            R Offline
            redace
            wrote on 20 Jul 2010, 11:58 last edited by
            #5

            Eureka !!

            I now understand what I missed. I had to layout contents of the scroll area.
            Like you put the scroll area within a grid layout.

            Thanks again for your help !

            1 Reply Last reply
            0
            • R Offline
              R Offline
              retro_code
              wrote on 14 Jan 2011, 21:32 last edited by
              #6

              redace, can you explain how you "layout the contents" of the scroll bar? I'm using some code from an example in Qt Assistant but it isn't working. This is an excerpt from what's in Qt Assistant:

              @ QSize areaSize = viewport()->size();
              QSize widgetSize = widget->size();

               verticalScrollBar()->setPageStep(widgetSize.height());
               horizontalScrollBar()->setPageStep(widgetSize.width());
               verticalScrollBar()->setRange(0, widgetSize.height() - areaSize.height());@
              

              Are you using something similar to that?

              1 Reply Last reply
              0
              • R Offline
                R Offline
                redace
                wrote on 15 Jan 2011, 00:47 last edited by
                #7

                Hey,

                It has been a while since I worked with QT.
                However I never used qt assistant. Only qt creator.

                I have no idea how I can layout the contents of the scroll bar itself.
                Below you can find the code of a .UI file with a simple scroll field so you can check it out for yourself.
                Maybe it is of some use to you.

                Hope it helps.

                @<?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>315</width>
                <height>489</height>
                </rect>
                </property>
                <property name="windowTitle">
                <string>MainWindow</string>
                </property>
                <widget class="QWidget" name="centralWidget">
                <widget class="QScrollArea" name="scrollArea">
                <property name="geometry">
                <rect>
                <x>20</x>
                <y>40</y>
                <width>261</width>
                <height>411</height>
                </rect>
                </property>
                <property name="widgetResizable">
                <bool>true</bool>
                </property>
                <widget class="QWidget" name="scrollAreaWidgetContents">
                <property name="geometry">
                <rect>
                <x>0</x>
                <y>0</y>
                <width>318</width>
                <height>518</height>
                </rect>
                </property>
                <layout class="QVBoxLayout" name="verticalLayout">
                <item>
                <widget class="QFrame" name="frame">
                <property name="minimumSize">
                <size>
                <width>300</width>
                <height>500</height>
                </size>
                </property>
                <property name="sizeIncrement">
                <size>
                <width>200</width>
                <height>0</height>
                </size>
                </property>
                <property name="baseSize">
                <size>
                <width>0</width>
                <height>0</height>
                </size>
                </property>
                <property name="frameShape">
                <enum>QFrame::StyledPanel</enum>
                </property>
                <property name="frameShadow">
                <enum>QFrame::Raised</enum>
                </property>
                <widget class="QPushButton" name="pushButton">
                <property name="geometry">
                <rect>
                <x>170</x>
                <y>250</y>
                <width>75</width>
                <height>23</height>
                </rect>
                </property>
                <property name="text">
                <string>PushButton</string>
                </property>
                </widget>
                <widget class="QPushButton" name="pushButton_2">
                <property name="geometry">
                <rect>
                <x>80</x>
                <y>470</y>
                <width>75</width>
                <height>23</height>
                </rect>
                </property>
                <property name="text">
                <string>PushButton</string>
                </property>
                </widget>
                </widget>
                </item>
                </layout>
                </widget>
                </widget>
                </widget>
                </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