Results 1 to 5 of 5

Thread: Resizing windows

  1. #1

    Default Resizing windows

    I'm a newbie in Qt programming. I downloaded QtCreater 1.2.1 using Qt 4.5.2. I'm going through one of the tutorials on creating a TextFinder. It is all working OK except I have a question regarding resizing windows.

    When I run the application, the window starts up. However, when I increase/decrease the size of the main windows, I would like to have the textarea and search text line expand/decrease appropriately.

    In the UI file, I have the size policy for LineEdit set to [Expanding, Fixed, 0,0]. For the textEdit it is set to [Expanding, Expanding, 0, 0]. But for some reason, these sub areas are not being resized as the parent window is resized.

    Can someone tell me how I can fix this? Are there some extra settings to be set in QtCreator?

    Thanks for your time.

  2. #2
    Join Date
    Jan 2006
    Location
    Innsbruck, Austria
    Posts
    62
    Thanks
    10
    Thanked 7 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Resizing windows

    As well as setting the size policy, did you add a layout?

  3. #3

    Default Re: Resizing windows

    Hi,

    Thanks for responding. Yes, I added a label, lineEdit, button to a QGridLayout and then added the QGridLayout and textEdit to a QVBoxLayout. But I can resize the parent window, but the text area and input field don't change.

    I'm pasting the contents of the UI file in case someone can tell me what I'm not doing correct.

    thanks

    ------------------------------------------------------------------------------------------------------
    <?xml version="1.0" encoding="UTF-8"?>
    <ui version="4.0">
    <class>RelosMain</class>
    <widget class="QMainWindow" name="RelosMain">
    <property name="geometry">
    <rect>
    <x>0</x>
    <y>0</y>
    <width>448</width>
    <height>310</height>
    </rect>
    </property>
    <property name="sizePolicy">
    <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
    <horstretch>0</horstretch>
    <verstretch>0</verstretch>
    </sizepolicy>
    </property>
    <property name="windowTitle">
    <string>RelosMain</string>
    </property>
    <widget class="QWidget" name="centralWidget">
    <property name="sizePolicy">
    <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
    <horstretch>0</horstretch>
    <verstretch>0</verstretch>
    </sizepolicy>
    </property>
    <widget class="QWidget" name="">
    <property name="geometry">
    <rect>
    <x>21</x>
    <y>12</y>
    <width>381</width>
    <height>238</height>
    </rect>
    </property>
    <layout class="QVBoxLayout" name="verticalLayout">
    <item>
    <layout class="QGridLayout" name="gridLayout">
    <item row="0" column="0">
    <widget class="QLabel" name="label">
    <property name="toolTip">
    <string extracomment="test"/>
    </property>
    <property name="whatsThis">
    <string extracomment="Find button"/>
    </property>
    <property name="text">
    <string>Keyword:</string>
    </property>
    </widget>
    </item>
    <item row="0" column="1">
    <widget class="QLineEdit" name="lineEdit">
    <property name="sizeIncrement">
    <size>
    <width>0</width>
    <height>0</height>
    </size>
    </property>
    <property name="font">
    <font>
    <family>Monaco</family>
    <pointsize>10</pointsize>
    </font>
    </property>
    </widget>
    </item>
    <item row="0" column="2">
    <widget class="QPushButton" name="findButton">
    <property name="sizePolicy">
    <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
    <horstretch>0</horstretch>
    <verstretch>0</verstretch>
    </sizepolicy>
    </property>
    <property name="toolTip">
    <string extracomment="test1"/>
    </property>
    <property name="statusTip">
    <string extracomment="test2"/>
    </property>
    <property name="whatsThis">
    <string extracomment="test3"/>
    </property>
    <property name="text">
    <string>Find</string>
    </property>
    </widget>
    </item>
    </layout>
    </item>
    <item>
    <widget class="QTextEdit" name="textEdit">
    <property name="sizePolicy">
    <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
    <horstretch>1</horstretch>
    <verstretch>1</verstretch>
    </sizepolicy>
    </property>
    <property name="sizeIncrement">
    <size>
    <width>0</width>
    <height>0</height>
    </size>
    </property>
    <property name="font">
    <font>
    <family>Monaco</family>
    <pointsize>10</pointsize>
    </font>
    </property>
    </widget>
    </item>
    </layout>
    </widget>
    </widget>
    <widget class="QMenuBar" name="menuBar">
    <property name="geometry">
    <rect>
    <x>0</x>
    <y>0</y>
    <width>448</width>
    <height>22</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>
    <layoutdefault spacing="6" margin="11"/>
    <resources/>
    <connections/>
    </ui>

  4. #4
    Join Date
    Apr 2008
    Location
    Cluj-Napoca, Romania
    Posts
    10
    Thanks
    5
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Resizing windows

    I had time to take a look at your form based on the code provided. The problem is that you didn't apply the layout to the central Widget. To apply the layout you should right click on the widget beneath the layout and select from the context menu: Lay Out->Lay out Vertically.

  5. #5

    Default Re: Resizing windows

    Hi,

    Thanks for the reply. That solved my problem.

Similar Threads

  1. I need example for Windows Mobile working program
    By Mr.QT in forum Qt Programming
    Replies: 3
    Last Post: 22nd June 2009, 09:19
  2. Qt Jambi, deploying app on Mac & Windows fails
    By ChrisColon in forum Installation and Deployment
    Replies: 2
    Last Post: 16th February 2009, 22:05
  3. Replies: 5
    Last Post: 15th January 2009, 09:03
  4. Windows not appearing in XP.
    By beardybloke in forum Qt Programming
    Replies: 7
    Last Post: 24th October 2007, 17:32
  5. converting unix exe to windows binary
    By deekayt in forum General Programming
    Replies: 2
    Last Post: 17th September 2006, 01:00

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.