PDA

View Full Version : Custom table header widget supporting dragging / resiging.



pavelspb
20th December 2012, 15:00
This http://savepic.org/2435615.png (marked with blue border) is what i want to implement. Lets call that thing MyWidget (large widget with table headers). As you see, it composed of smaller widgets, lets call them HeaderWidget. I need 2 things: (1) animated moving of the headers, (2) mouse cursor change to "<-->" when it goes close to border between the HeaderWidgets of the "table".

(1) Animation is not a problem: my idea is based on QTimer that "lazily" changes coordinates (with some nice math, like sine or n/2...) while they differs from "goal coordinates". We change only goal coordinates, QTimer do the rest of the job.

(2) The problem is detection or border approach. We assume that "headers" is a widgets (HeaderWidget), not just hand-drawn rectangles (the HeaderWidget can be "rich" like this: http://savepic.ru/3656121.png (see the header of each track)), than every pixel of MyWidget is used by some child widget. For this reason, MyWidget doesn't see mouse movements - mouseMove events consumed by subwidgets. So MyWidget cannot host algorithm for detecting borders approach.

The 1st idea is to allow widget change its size depending on mouse behavior and generate signals, like "i changed my size because of dragging left border" or "i c m s b of dragging RIGHT border". This is important to allow MyWidget change sizes of neighbour HeaderWidgets.

The 2nd idea is to place small unvisible widgets between the HeaderWidgets. Tha widgets would perform "border dragging" and change mouse cursor to "<-->". But i don't like the idea of increasing number of widgets: too many connect/disconnect calls is a mess :) And the problem with this approaach is that i need to guarantee that the small widgets would always be on top of all other widgets.

Any more ideas?