PDA

View Full Version : resizing graphicsView when user resizes mainwindow



mirelon
20th December 2009, 23:43
I'd like when the user resizes the main window of my app, the graphicsView to be resized too (that it scales the graphics scene)

Structure of the widgets is:


main window
central widget with layout
graphics view

I am using Qt Creator 1.3.0 based on Qt 4.6.0 working on windows.

UI is as follows:


<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Marias</class>
<widget class="QMainWindow" name="Marias">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>802</width>
<height>641</height>
</rect>
</property>
<property name="windowTitle">
<string>OpenMarias</string>
</property>
<widget class="QWidget" name="centralWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="cursor">
<cursorShape>ArrowCursor</cursorShape>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QGraphicsView" name="graphicsView">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="cursor" stdset="0">
<cursorShape>ArrowCursor</cursorShape>
</property>
<property name="styleSheet">
<string notr="true">background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 rgba(0, 0, 0, 255), stop:1 rgba(0, 120, 0, 255));</string>
</property>
<property name="lineWidth">
<number>1</number>
</property>
<property name="backgroundBrush">
<brush brushstyle="NoBrush">
<color alpha="255">
<red>16</red>
<green>127</green>
<blue>35</blue>
</color>
</brush>
</property>
<property name="interactive">
<bool>true</bool>
</property>
<property name="sceneRect">
<rectf>
<x>0.000000000000000</x>
<y>0.000000000000000</y>
<width>800.000000000000000</width>
<height>600.000000000000000</height>
</rectf>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="resizeAnchor">
<enum>QGraphicsView::NoAnchor</enum>
</property>
<property name="viewportUpdateMode">
<enum>QGraphicsView::MinimalViewportUpdate</enum>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>802</width>
<height>20</height>
</rect>
</property>
<widget class="QMenu" name="menuGame">
<property name="title">
<string>Game</string>
</property>
<addaction name="actionNew_game"/>
<addaction name="actionQuit"/>
<addaction name="actionSettings"/>
</widget>
<widget class="QMenu" name="menuHelp">
<property name="title">
<string>Help</string>
</property>
<addaction name="actionAbout"/>
</widget>
<addaction name="menuGame"/>
<addaction name="menuHelp"/>
</widget>
<widget class="QStatusBar" name="statusBar"/>
<action name="actionNew_game">
<property name="text">
<string>New game</string>
</property>
<property name="shortcut">
<string>Ctrl+N</string>
</property>
</action>
<action name="actionQuit">
<property name="text">
<string>Quit</string>
</property>
<property name="shortcut">
<string>Esc, Ctrl+Q</string>
</property>
</action>
<action name="actionAbout">
<property name="text">
<string>About</string>
</property>
</action>
<action name="actionSettings">
<property name="text">
<string>Settings</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>