Dynamically creating push buttoms based on how many items are needed based on the amount
-
i thought that would be the way to do it, hmm, guess not. LOL
-
The best approach to take, depends on what you actually want to achieve. That is not quite clear from your question. You talk about buttons to hold data, and then you suggest that a list might be an option.
You can of course dynamically generate buttons to represent each material, but is that really what you want? Such a material list might perhaps be better presented as a list or a table. In that case, the model-view programming would be the way to go. Within that context, there are several ways to do that. If you let us know what you would like to achieve, we can help you to get there.
-
well, i kinda wanted to make a UDK content browser like system (UDK is in my opinion the best made engine around) and while i don't want to drive them out of business (unlikely) i'd like to get an editor going like theirs BSP and CSG still kinda confuse me but i'll get there when i get there
-
sure, why not?
creatzing buttons is just new QPushButton
if you want to take pointer, i would do the following:@
QVector<QPointer<QPushButton> > vec;for(int i = 0; i < 10; ++i) { QPointer<QPushButton> p = new QPushButton(this); myLayout->addWidget(p); vec.append(p); }
@
-
Well, if you want to go that way, then I would extend the above a little bit...
@
QVector<QPointer<QPushButton> > vec;QSignalMapper* smap = new QSignalMapper(this); for(int i = 0; i < 10; ++i) { QPointer<QPushButton> p = new QPushButton(this); myLayout->addWidget(p); vec.append(p); connect (p, SIGNAL(clicked()), smap, SLOT(map())); smap->setMapping(p, vec.count() -1); } connect (smap, SIGNAL(mapped(int)), this, SLOT(buttonClicked(int)));
@
That way, you can actually do some useful work when a button is clicked (though you of course have to actually implement a method called buttonClicked(int) ).
However, depending on the number of materials you wish to present, I would still considder a list first. You can also respond to selections in that list or (double) clicks on items in the list. Seems like a more scalable solution than just creating a load of buttons without knowing how many you might need. At least a list would be easy to expand (add filtering, sorting, etc) so it stays manageable for the user.
-
!http://img.photobucket.com/albums/v238/adarksoul/UDK.png?t=1300880144(UDK content browser)!
here's a pic of the content browser
-
well, all the items in the bigger window are buttons based on the contenct in UDK's packages, least I assume they are buttons,when u click on one it high lights and when you double click it opens what ever window that button is associated with
-
No, I would not think they are buttons. They are items in an item view, with some custom rendering. Just like you get when you view a directory with images in your explorer in preview mode.
What you are after, I think, is a QListView (or possibly a QListWidget) set in icon mode.