You should parse and set accordingly.
Create a QWidget, parse the first line of the text file, set its size. Then parse next lines to get the number of buttons, create widgets dynamically. Something like:
// main
// ...
QString geoLine = stream.readLine();
int width = geoLine.split(" ")[1].toInt();
int height = geoLine.split(" ")[2].toInt();
QWidget * widget = new QWidget();
widget->setGeometry(0, 0, width, height);
// create a layout for the child widgets, then create and add them dynamically.
QVBoxLayout * layout = new QVBoxLayout();
int nButtons = stream.readLine().split(" ")[1];
// full control of dynamically created objects
QList<QPushButton *> buttons;
while(nButtons > 0) {
QPushButton * button = new QPushButton();
buttons.append(button);
layout.addWidget(button);
nButtons--;
}
// same for radio buttons
// ...
widget->setLayout(layout);
widget->show();
// ... etc, app exec,
qDeleteAll(buttons);
delete widget;
return 0;
If you want to learn the widget type from push_button
or radio_button
directives; you must switch - case onto those parsed strings.
There is also completely another way. You can create a form (.ui) file using an XML data. You must create a ui class (like the template designer form class created by Qt), and create its .ui file according to your text file - parsed and converted to a proper XML.
As far as I know Qt handles the widget creations using that XML information, and generates the file ui_YourClass.h
..