PDA

View Full Version : Qt Splitter signals slots (how to do a quad view)



ZarehG
2nd March 2010, 17:40
Hi,

I'm trying to use signals and slots to make one splitter move as another splitter is moved. Basically I'm trying to tie two splitters together so that if one is moved left or right, the other one mirrors it's actions.

I have 4 areas, imagine a 2x2 setup. I have a horizontal splitter separating the top 2 "boxes/windows" from the bottom 2 "boxes/windows" and have 2 vertical splitters separating the 2 "boxes/windows" on top from each other, and the two "boxes//windows" on the bottom from each other. When I move one of the vertical splitters, I want the other one to move too. I couldn't find a slot in QtDesigner for a splitter for it's coordinates.

Any help would be greatly appreciated.

here is my .ui file, just cut and paste it in a file called QuadSplitter.ui and you can load it into QtDesigner:
__________________________________________________ ____________________________________
<?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>923</width>
<height>809</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QSplitter" name="splitter_3">
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<widget class="QSplitter" name="splitter_2">
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<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>422</width>
<height>366</height>
</rect>
</property>
</widget>
</widget>
<widget class="QScrollArea" name="scrollArea_2">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents_2">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>469</width>
<height>366</height>
</rect>
</property>
</widget>
</widget>
</widget>
<widget class="QSplitter" name="splitter">
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<widget class="QScrollArea" name="scrollArea_3">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents_3">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>422</width>
<height>411</height>
</rect>
</property>
</widget>
</widget>
<widget class="QScrollArea" name="scrollArea_4">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents_4">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>469</width>
<height>411</height>
</rect>
</property>
</widget>
</widget>
</widget>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

Lykurg
2nd March 2010, 20:42
What's about QSplitter::splitterMoved() and the parameter index, which is the "x coordinate". Designer is a great tool, but sometimes you have to handle signal and slots in your c++ code yourself...

ZarehG
2nd March 2010, 20:55
Yes, that was the answer. As you pointed out it doesn't seem doable from QtDesigner.

thank you Lykurg,
Zareh