
Originally Posted by
Kumosan
Do you have a different designer? I mine I don't see 'Button Group' in the widget box.
QButtonGroup is not a widget.
Of course, you can add all buttons manually into a QButtonGroup. But then the code has to change when you add another button. With QLineEdits it is even worse, there is no such thing like a QLineEditGroup.
When you don't use Designer you have to add these buttons to the buttongroup yourself anyway, so I don't see where the "hand code only" way is superior...
But I might believe that for all my problems a workaround is possible. Only that if you constantly have think of workarounds for the shortcomings of the designer, the speed bonus is quickly gone.
I think you're the one making workarounds... Query? Register? Factory? Aren't these workarounds?
A graphically designable parent/child tree like the QObject parent/child tree + some attachable meta informations. I call this designer meta objects. The designer would automatically generate a query method and a factory method. The query method gives you a list of meta objects. The factory method creates meta objects.
Could you suggest any other use than yours for such a feature? How is this related to a layout editor?
If this is done right, you could start your designer, add a couple of widgets like buttons or lineedits, and it would still work without a single line of code changed in your program.
I don't see a problem with doing it without any changes to designer. Just like you have automatic signal-slot connections, you can make automatic "button group additions", for example based on object names, try this:
QList<QPushButton
*> candidates
= findChildren<QPushButton
*>
(QRegExp("bgbutton_[0-9]+"));
rx.exactMatch(candidate->objectName());
buttongroup->addButton(candidate, rx.cap(1).toInt());
}
QList<QPushButton*> candidates = findChildren<QPushButton*>(QRegExp("bgbutton_[0-9]+"));
foreach(QPushButton *candidate, candidates){
QRegExp rx("bgbutton_([0-9]+)");
rx.exactMatch(candidate->objectName());
buttongroup->addButton(candidate, rx.cap(1).toInt());
}
To copy to clipboard, switch view to plain text mode
No need to change a single line of code outside Designer... You can do the same thing with other widgets as well... even making automatic connections for line edits or whatever you want.
Creating such a parent/child relationship would be as easy a putting objects on a layout tree.
What layout tree?
Bookmarks