0
我有一个带有标签和QGraphicsView的垂直布局。我已经设置了QGraphicsView的最大尺寸,并将水平对齐设置为AlignHCenter,但它似乎仍然出现在左侧而不是已知的?这里是一个演示UI文件:最大尺寸的小工具没有遵循AlignHCenter
<?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="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>TextLabel</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QGraphicsView" name="graphicsView">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>100</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
如果我改变标签的水平对齐方式,它的行为,我期望(左移动到左边,AlignHCenter它移动到中心),但的QGraphicsView不遵循这种行为 - 它总是在左边。
我该如何居中这个固定大小的QGraphicsView?