{
{
return;
}
if (!document.setContent(&file))
{
file.close();
return;
}
while (!node.isNull())
{
if (!param.isNull())
{
if (param.tagName() != "Parameter")
{
continue;
}
if (param.attribute("type") == "textfield")
{
QDomElement labelElem
= node.
firstChildElement("Label");
QDomElement toolTip
= node.
firstChildElement("ToolTip");
lineEdit->setMaximumWidth(size.text().toInt());
lineEdit->setToolTip(toolTip.text());
int row = layout->rowCount();
layout->addWidget(label, row, 0);
layout->addWidget(lineEdit, row, 1);
}
}
node = node.nextSibling(); }
}
void ReportParametersDialog::processXmlFile(const QString &xmlFile, QGridLayout *layout)
{
QDomDocument document("parameters");
QFile file(xmlFile);
if (!file.open(QIODevice::ReadOnly))
{
return;
}
if (!document.setContent(&file))
{
file.close();
return;
}
QDomElement root = document.documentElement();
QDomNode node = root.firstChild();
while (!node.isNull())
{
QDomElement param = node.toElement();
if (!param.isNull())
{
if (param.tagName() != "Parameter")
{
continue;
}
if (param.attribute("type") == "textfield")
{
QDomElement labelElem = node.firstChildElement("Label");
QLabel *label = new QLabel(labelElem.text());
QDomElement value = node.firstChildElement("Value");
QDomElement size = node.firstChildElement("Size");
QDomElement toolTip = node.firstChildElement("ToolTip");
QLineEdit *lineEdit = new QLineEdit(value.text());
lineEdit->setMaximumWidth(size.text().toInt());
lineEdit->setToolTip(toolTip.text());
int row = layout->rowCount();
layout->addWidget(label, row, 0);
layout->addWidget(lineEdit, row, 1);
}
}
node = node.nextSibling(); }
}
To copy to clipboard, switch view to plain text mode
I thought about using QSignalMapper but I don't see how to detect if the value of any widget has changed without storing the value somewhere.
Do you have any better idea?
Regards,
Franco
Bookmarks