Dynamically creating push buttoms based on how many items are needed based on the amount
-
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
-
Problem is, that that really doesn't tell me anything. I am not familiar with UDK, BSP or CSG. Could you post a screenshot of what you're after?
-
cant you form a button in your 'while' loop and use an array to keep track?
-
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
-
Which part is the part you're trying to re-create?
First observation is that at least, there doesn't seem to be a big list of buttons somewhere in this interface...
-
What I see is a list of checkable items. Did you want to create check boxes for them? There it would be easier to use a Model - view aproach with checkable items from the DataModel.
-
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.