|
涅槃 发表于 2014-6-7 10:31
我现在在文件名中只输入后缀时,按下另存为对话框的保存按钮时,提示他文件名不能为空,不保存。可是实现不 ... -
- QString name = MdiArea->activeSubWindow()->objectName();
- MyWidget *widget = static_cast<MyWidget *>(MdiArea->activeSubWindow()->widget());
- QDomDocument doc;
- doc.appendChild(doc.createProcessingInstruction("xml","version="1.0" encoding="UTF-8""));
- QDomElement root = doc.createElement(name);
- doc.appendChild(root);
- //QComboBox
- QList<QComboBox *> allcombobox = widget->findChildren<QComboBox *>();
- if(allcombobox.size() != 0){
- QDomElement typecom = doc.createElement("QComboBox");
- root.appendChild(typecom);
- foreach (QComboBox *box, allcombobox) {
- QDomElement child = doc.createElement(box->objectName());
- child.setAttribute("Text",box->currentText());
- child.setAttribute("Index",box->currentIndex());
- typecom.appendChild(child);
- }
- }
复制代码 以上是从我的项目里截取的一部分代码,你可以参考一下,希望对你有帮助。
|
|