Signals and RAD GUI design ?
(I am newbie here, I evaluate Qt Creator for only 3 weeks)
It started by working on a QGraphicsView-QGraphicsScene with mouse pan/zoom, and I couldn't find the signals of the QGraphicsView.
Please reassure me that I am not not totally misguided:
Original widgets lack most of the signals (e.g. mouse move, buttonpress/release etc.) I have to create own classes inherited from original system's classes, and override the event-handling functions this way. These functions can emit signals or simply they themselves do whatever must be done. And of course these overriden functions have their dedicated names (which are hard to find in doc's; we have to take a look for their source)
And making my own classes, I can't use the GUI designer: I have to create and place all screen objects at runtime from code.
Why are all possible signals (== event handler calls) left out at most widgets? Performance problems (even if these signals wouldn't be connected to anyone)?
Already discussed here http://developer.qt.nokia.com/forums/viewthread/3260/
[quote]And making my own classes, I can’t use the GUI designer: I have to create and place all screen objects at runtime from code. [/quote]
You can "promote" a widget to your subclass.
You can use GUI designer to design interface itself, and then create your own class just to add functionality to GUI. If you're new to Qt, there is a book "Qt Foundations" that is great in explaining connections between widgets and classes that actualy do something.
So the usual graphical app. design should be
-drop a widget on the creator's form,
-set size/placement/stylesheet etc. of the widget in Creator
-edit .cpp to create a sublass for that widget's class
-promote visually placed widget to the newly created subclass
-override widget's event-handling functions to emit proper signals (or simply do the stuff in the event-handler without signalling. Still can't see the advantage of signal/slot system over event handling. It seems to me that signal/slot system is a new layer above the eventhandling level)
Am I right? Opinions?
Where can I find reference of possible events (what eventhandler function names to override) for actual Q objects? Do I have to check their source?
[quote author="novaktamas" date="1296677648"]
Where can I find reference of possible events (what eventhandler function names to override) for actual Q objects? Do I have to check their source?[/quote]
I've successfully edited my own personal clone of qt and added signals for relevant qwidget events like focusIn, focusOut, mouseEnter, mouseLeave, mousePress, mouseRelease, mouseClick (even added a mouseClick event handler), mouseDoubleClick, keyPress, keyRelease, show, hide, move, resize, and maybe other events I don't remember right now.
You just need to declare the signals and emit them at the end of the corresponding event handler function.
For the record I think this should be a standard for Qt, but hey.. that's the best thing about open source, you can hack it at your will.