tags:

views:

180

answers:

2
+1  Q: 

Attach Qt windows?

Is there any way to attach two Qt windows together? For example, if window A is the main window and window B is another widget I want to be able to show window B to the side of A and have both windows move together if the windows are dragged.

+3  A: 

Not that I am aware of, but you can try following the trail of QMoveEvent. When a given widget is moved void QWidget::moveEvent ( QMoveEvent * event ) is called, and the QMoveEvent contains both old and new pos. Using this information, you can inject a move event in the other widget as well, and make it follow.

Of course, I am speaking of two independent widgets, each one in its own window. If they are contained, you don't need anything but a Layout management (see QLayout and related classes).

I don't work with Qt since a long time, so there could be a better method, but if I had to do it right now, this is the strategy I would use.

Also, I have the feeling that the QMoveEvent will be invoked only at start and end, unless you enable mouse tracking. If the former is the case, you will obtain that the other widget will "teleport" at the end of the move, instead of following smoothly.

Stefano Borini
+1  A: 

You might be after something like this:

http://doc.trolltech.com/4.5/qt4-mainwindow.html

Window A would be a QMainWindow and window B would be a QDockWidget.

Dave
Window B must be on the side of windows A, not in Window A
TimW
I think we need the original poster to clarify what is required - the current question could have been an attempt to describe either case.That's why I qualified my response with the weasely "might" :)
Dave