PDA

View Full Version : How to create Custom Slot upon widgets



ashukla
7th September 2007, 10:36
How to create Custom Slot upon widgets in Qt4.
In Qt4 .ui.h is available or not? If available how a way I can access?
I am not getting a way in Qt4.
Plz. help.

marcel
7th September 2007, 11:04
You can create a custom slot upon your widget by reading: http://doc.trolltech.com/4.3/designer-using-a-component.html.

Regards

Raccoon29
7th September 2007, 17:10
You can create a custom slot upon your widget by reading: http://doc.trolltech.com/4.3/designe...component.html.

Hi, I read it too, and I would pose a question about the custom slots:
so, how do I decide which type of inheritance is better use? I mean, which are the points to follow to decide? I didn't understand reading it... :confused:

Thanks
Greetings

jpn
7th September 2007, 19:47
so, how do I decide which type of inheritance is better use? I mean, which are the points to follow to decide?
This is what docs have to say about these two approaches:

The Single Inheritance Approach
The main advantages of this approach are its simple use of inheritance to provide a QWidget-based interface, and its encapsulation of the user interface widget variables within the ui data member. We can use this method to define a number of user interfaces within the same widget, each of which is contained within its own namespace, and overlay (or "compose") them. This approach can be used to create individual tabs from existing forms, for example.

The Multiple Inheritance Approach
Subclassing using multiple inheritance gives us more direct access to the contents of the form, is slightly cleaner than the single inheritance approach, but does not conveniently support composition of multiple user interfaces.

One of the things that I personally do like in single inheritance approach is that it makes it slightly easier to read (unfamiliar) code. Designed UI components are referred via special UI object. This makes it clear where a certain variable is declared. In multiple inheritance approach member variables are declared in a separate auto generated header file. Of course, a simple naming convention would do the same trick in multiple inheritance approach too. :)

Raccoon29
8th September 2007, 13:56
One of the things that I personally do like in single inheritance approach is that it makes it slightly easier to read (unfamiliar) code.

Thank you for the answer,
but isn't it going to be annoy to refer to the Ui object everytime you have to use a ui form component? I hope in your personal experience :o

marcel
8th September 2007, 14:02
I don't believe its annoying.
As jpn pointed out it is more cleaner. You always know a certain widget is in the UI class.

Regards

Raccoon29
8th September 2007, 14:07
Ok,
thank you all very much :)