[Qt-interest] Events and objects...
BRM
bm_witness at yahoo.com
Wed Feb 9 00:37:47 CET 2011
I'm revisiting a problem I partially solved a while ago per layouts and snapping
widgets in and out. The old solution derived from QGridLayout and required a
customized widget to interact with it; however, it is problematic in that it
does not always clear out the columns. I had thought of a couple other
approaches, one of which I am now attempting, but I find there may be a
problem...
Original Approach
- Derive a new object that checks the mouse double click event. The new object
basically just says if it has a parent, then pop it out; otherwise, pop it back
in.
- Derive a new sub layout from QGridLayout that receives a signal on the pop
in/out events to do so; adding/removing it as appropriate, and keeping track of
removed widgets.
- If a widget is removed, then free up the grid above it so things can slid up
(primarily done only when everything is remove from the display).
New Approach 1
- Instead of using QGridLayout, derive from QLayout.
- Use a master QHBoxLayout to manage the columns with each column having its own
QVBoxLayout
- Add/remove items to each column as desired via insertWidget() to get it in the
right spot.
- Logic for the pop in/pop out is still in the layout
New Approach 2
- Like New Approach 1 but use the approach of QMdiArea
- Instead of using a specialized QWidget to like in the Original Approach, use a
custom QWidget (aka QSubWidget) that manages a single normal QWidget.
- Manage the pop in/out from the QSubWidget
I'd really like to do New Approach 2 as it makes the whole thing a little more
generic - and my other widgets don't need to be specifically derived from the
custom widget, as done in my original approach.
However, to do so the QSubWidget needs to have access to the mouse double-click
event from the normal QWidget - which at least in Qt 4.5 is a protected virtual
function.
My question is - without requiring something to be specifically derived from a
specific class, is there a way to access the mouse double-click events of
another widget?
I basically need to just know when a double click happens - even if there was an
associated signal with the double click it would suffice.
Or is there a better approach?
TIA,
Ben
More information about the Qt-interest-old
mailing list