PDA

View Full Version : Custom Items for QListWidget



Archa4
2nd February 2011, 11:18
As I understood from reading meny threads, I have to create a custom widget, that i will be able to use as Items for QListWidget is that correct?
If it is, could u give me some links or describe how to create your own/custom widgets?
Sorry for noob question.

high_flyer
2nd February 2011, 11:29
I have to create a custom widget, that i will be able to use as Items for QListWidget is that correct?
It depends on what your needs are.

Archa4
2nd February 2011, 11:32
I need a list of items, where each item consists of a label and 4 buttons.

high_flyer
2nd February 2011, 11:48
If it is, could u give me some links or describe how to create your own/custom widgets?
Then yes, you will need to create a custom widget.


If it is, could u give me some links or describe how to create your own/custom widgets?
Nothing special about it.
You just subclass the appropriate widget class and add the other widgets as members.
This is basic C++ stuff.
If you know how to subclass, you know how to create custom widgets.
Unless you mean with your question something more specific - in that case please elaborate.

Archa4
2nd February 2011, 11:49
just subclass the appropriate widget class and add the other widgets as members.


Which would be the appropriate widget class in this situation?

Turns out i'll need a picture to... How to add a picture to mine custom widget?

high_flyer
2nd February 2011, 11:54
Which would be the appropriate widget class in this situation?
I would use a QWidget, since there is no functionality you need to subclass, except it being a widget.
But QLabel or QFrame would also work.
you can have a look how a custom widget is done here:
http://doc.trolltech.com/4.7/designer-creating-custom-widgets.html

This is more about how to create a designer plugin, but part of it is creating a custom widget, which you can look at.

Archa4
2nd February 2011, 12:13
I would use a QWidget, since there is no functionality you need to subclass, except it being a widget.
But QLabel or QFrame would also work.
you can have a look how a custom widget is done here:
http://doc.trolltech.com/4.7/designer-creating-custom-widgets.html

This is more about how to create a designer plugin, but part of it is creating a custom widget, which you can look at.

Thanks! But what about the picture?

high_flyer
2nd February 2011, 12:17
What about it?

Archa4
2nd February 2011, 12:23
which widget should i use to add a picture to mine customized widget?

high_flyer
2nd February 2011, 12:30
Well, how about you first read the docs a bit?
And also look at the links in my previous post in this thread.
There most of the information you are asking about is there.
If you encounter problems or need further help you are welcome to ask again.

Archa4
2nd February 2011, 13:51
Hm.. Every thread and every link I look - I can't find step by step walhthrough on how to create youw own widget. Which option should I select in create new project?

Added after 1 4 minutes:

OK, somehow i got around that just merging those 2 files into mine project.
Now i have a different kind of problem - how can i resize QListWidget elements? I want to make all of them to be constant, but bigger size that they are now...

Added after 7 minutes:

OK, i was able to resolve that problem as well (setSizeHint(QSize(xx, xx)).
Thanks for help!