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:

Qt Code:
  1. main window
  2. central widget with layout
  3. graphics view
To copy to clipboard, switch view to plain text mode 

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

UI is as follows:
Qt Code:
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <ui version="4.0">
  3. <class>Marias</class>
  4. <widget class="QMainWindow" name="Marias">
  5. <property name="geometry">
  6. <rect>
  7. <x>0</x>
  8. <y>0</y>
  9. <width>802</width>
  10. <height>641</height>
  11. </rect>
  12. </property>
  13. <property name="windowTitle">
  14. <string>OpenMarias</string>
  15. </property>
  16. <widget class="QWidget" name="centralWidget">
  17. <property name="sizePolicy">
  18. <sizepolicy hsizetype="Maximum" vsizetype="Maximum">
  19. <horstretch>0</horstretch>
  20. <verstretch>0</verstretch>
  21. </sizepolicy>
  22. </property>
  23. <property name="cursor">
  24. <cursorShape>ArrowCursor</cursorShape>
  25. </property>
  26. <layout class="QVBoxLayout" name="verticalLayout">
  27. <property name="spacing">
  28. <number>0</number>
  29. </property>
  30. <property name="margin">
  31. <number>0</number>
  32. </property>
  33. <item>
  34. <widget class="QGraphicsView" name="graphicsView">
  35. <property name="sizePolicy">
  36. <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
  37. <horstretch>0</horstretch>
  38. <verstretch>0</verstretch>
  39. </sizepolicy>
  40. </property>
  41. <property name="cursor" stdset="0">
  42. <cursorShape>ArrowCursor</cursorShape>
  43. </property>
  44. <property name="styleSheet">
  45. <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>
  46. </property>
  47. <property name="lineWidth">
  48. <number>1</number>
  49. </property>
  50. <property name="backgroundBrush">
  51. <brush brushstyle="NoBrush">
  52. <color alpha="255">
  53. <red>16</red>
  54. <green>127</green>
  55. <blue>35</blue>
  56. </color>
  57. </brush>
  58. </property>
  59. <property name="interactive">
  60. <bool>true</bool>
  61. </property>
  62. <property name="sceneRect">
  63. <rectf>
  64. <x>0.000000000000000</x>
  65. <y>0.000000000000000</y>
  66. <width>800.000000000000000</width>
  67. <height>600.000000000000000</height>
  68. </rectf>
  69. </property>
  70. <property name="alignment">
  71. <set>Qt::AlignCenter</set>
  72. </property>
  73. <property name="resizeAnchor">
  74. <enum>QGraphicsView::NoAnchor</enum>
  75. </property>
  76. <property name="viewportUpdateMode">
  77. <enum>QGraphicsView::MinimalViewportUpdate</enum>
  78. </property>
  79. </widget>
  80. </item>
  81. </layout>
  82. </widget>
  83. <widget class="QMenuBar" name="menuBar">
  84. <property name="geometry">
  85. <rect>
  86. <x>0</x>
  87. <y>0</y>
  88. <width>802</width>
  89. <height>20</height>
  90. </rect>
  91. </property>
  92. <widget class="QMenu" name="menuGame">
  93. <property name="title">
  94. <string>Game</string>
  95. </property>
  96. <addaction name="actionNew_game"/>
  97. <addaction name="actionQuit"/>
  98. <addaction name="actionSettings"/>
  99. </widget>
  100. <widget class="QMenu" name="menuHelp">
  101. <property name="title">
  102. <string>Help</string>
  103. </property>
  104. <addaction name="actionAbout"/>
  105. </widget>
  106. <addaction name="menuGame"/>
  107. <addaction name="menuHelp"/>
  108. </widget>
  109. <widget class="QStatusBar" name="statusBar"/>
  110. <action name="actionNew_game">
  111. <property name="text">
  112. <string>New game</string>
  113. </property>
  114. <property name="shortcut">
  115. <string>Ctrl+N</string>
  116. </property>
  117. </action>
  118. <action name="actionQuit">
  119. <property name="text">
  120. <string>Quit</string>
  121. </property>
  122. <property name="shortcut">
  123. <string>Esc, Ctrl+Q</string>
  124. </property>
  125. </action>
  126. <action name="actionAbout">
  127. <property name="text">
  128. <string>About</string>
  129. </property>
  130. </action>
  131. <action name="actionSettings">
  132. <property name="text">
  133. <string>Settings</string>
  134. </property>
  135. </action>
  136. </widget>
  137. <layoutdefault spacing="6" margin="11"/>
  138. <resources/>
  139. <connections/>
  140. </ui>
To copy to clipboard, switch view to plain text mode