में QInputDialog से कई इनपुट प्राप्त करना मैं QtCreator में चार इनपुट लेबल से चार मानों का एक सेट प्राप्त करना चाहता हूं। मैं QInputDialog
का उपयोग करना चाहता हूं लेकिन इसमें डिफ़ॉल्ट रूप से केवल एक inputbox
शामिल है। तो, मैं चार लेबल और चार लाइन-संपादन कैसे जोड़ सकता हूं और इससे मूल्य प्राप्त कर सकता हूं?QtCreator
15
A
उत्तर
18
आप नहीं करते हैं। प्रलेखन बहुत स्पष्ट है:
QInputDialog वर्ग एक एकल उपयोगकर्ता से मूल्य प्राप्त करने के लिए एक सरल सुविधा संवाद प्रदान करता है।
यदि आप एकाधिक मान चाहते हैं, तो 4 इनपुट फ़ील्ड के साथ स्क्रैच से QDialog
व्युत्पन्न कक्षा बनाएं।
उदाहरण के लिए:
QDialog dialog(this);
// Use a layout allowing to have a label next to each field
QFormLayout form(&dialog);
// Add some text above the fields
form.addRow(new QLabel("The question ?"));
// Add the lineEdits with their respective labels
QList<QLineEdit *> fields;
for(int i = 0; i < 4; ++i) {
QLineEdit *lineEdit = new QLineEdit(&dialog);
QString label = QString("Value %1").arg(i + 1);
form.addRow(label, lineEdit);
fields << lineEdit;
}
// Add some standard buttons (Cancel/Ok) at the bottom of the dialog
QDialogButtonBox buttonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel,
Qt::Horizontal, &dialog);
form.addRow(&buttonBox);
QObject::connect(&buttonBox, SIGNAL(accepted()), &dialog, SLOT(accept()));
QObject::connect(&buttonBox, SIGNAL(rejected()), &dialog, SLOT(reject()));
// Show the dialog as modal
if (dialog.exec() == QDialog::Accepted) {
// If the user didn't dismiss the dialog, do something with the fields
foreach(QLineEdit * lineEdit, fields) {
qDebug() << lineEdit->text();
}
}
संबंधित मुद्दे
- 1. QtCreator
- 2. QtCreator
- 3. QTCreator
- 4. QtCreator
- 5. QtCreator
- 6. QtCreator
- 7. कैसे QtCreator
- 8. Qt5.1-एंड्रॉयड: QtCreator
- 9. QtCreator CodeSourcery Toolchain
- 10. QtCreator कई परिभाषा निर्माण बग
- 11. QtCreator/qmake अतिरिक्त लक्ष्य रन
- 12. CDB डीबगर के साथ QtCreator डिबग
- 13. QTCreator के साथ ऑटो-जेनरेटर सेटर्स/गेटर्स?
- 14. स्वचालित रूप से कई सामान्य QtCreator परियोजनाओं
- 15. QtCreator: कोई वैध किट नहीं मिली
- 16. QtCreator no debugger सेट अप (विंडोज)
- 17. QtCreator टूलटिप्स में API दस्तावेज़ कैसे दिखाएं?
- 18. लिनक्स पर QtCreator: 32-बिट्स बनाम 64-बिट्स
- 19. QTCreator फ़ाइलों को आउटपुट निर्देशिका में कॉपी करें
- 20. कई libs के साथ QtCreator प्रोजेक्ट और एक exe
- 21. QtCreator का उपयोग कर डीएलएल प्रोजेक्ट को डीबग कैसे करें?
- 22. QtCreator में C++ रनटाइम लाइब्रेरी सेटिंग को कैसे बदलें?
- 23. QtCreator: स्रोत कोड के लिए केंद्रीय "हेडर" (कॉपीराइट, लेखक)
- 24. QDeclarativeV ऐसी कोई फ़ाइल ot निर्देशिका नहीं देखें। QtCreator
- 25. QtCreator Kits के बारे में डेटा कहां रखता है?
- 26. QtCreator: डिबगिंग के लिए पैरामीटर कैसे सेट करें?
- 27. QtCreator में opencv को कैसे लिंक करें और क्यूटी लाइब्रेरी
- 28. रिटर्न QtCreator निर्माण collect2: ld बाहर निकलें स्थिति 1
- 29. QtCreator में किसी प्रोजेक्ट के लिए फ़ोल्डर या उपनिर्देशिका कैसे बनाएं?
- 30. मैं QtCreator में स्थानीय और वॉचर्स पैनल की स्थिति कैसे बदलूं?
यह संभव था इनपुट के खेतों और संवाद बॉक्स में लेबल के लिए? –
@ गोथम मैंने अपने जवाब में एक उदाहरण जोड़ा। – alexisdm
QDialogButtonBox के उल्लेख के लिए बहुत धन्यवाद, मुझे जो चाहिए था लेकिन नहीं मिला ... –