Hi,
is it possible to create a small QWidget with some QLineEdits, which returns the content of these QLineEdits after closing the QWidget?
Or is a QDialog more suitable to implment this functionality?
Thanks
Micha
Hi,
is it possible to create a small QWidget with some QLineEdits, which returns the content of these QLineEdits after closing the QWidget?
Or is a QDialog more suitable to implment this functionality?
Thanks
Micha
Hi,
A QDialog is useful when you want the user to take a decision before continuing a process. For example, ask for an answer before deleting a file. If this is the case, use QDialog.
Carlos.
Ok, then I should use a QWidget, because the user shall enter some values in QLineEdits and after closing the widget these values should be available in the parent window.
That depends. You can call QDialog with exec() so it appears as modal (the user cannot interact with other windows (including the parent) until it close the dialog). If the user can interact with the parent while the window with edits is on the screen then you can use a QDialog but calling show() or a QWidget.
OK, if I would use QDialog with the exec function. How can I return the values from the QLineEdits to the parent widget?
ok You create a C++ class based on QDialog. Using QT designer for example. Say you called it myDialogWithEdits.
This class has in its ui the edits. Because the ui is private you need to create a public function to get the value from the edits. Lets call it getValueOfEditOne().
in the .h
Qt Code:
public:To copy to clipboard, switch view to plain text mode
in the .cpp
Qt Code:
myDialogWithEdits::getValueOfEditOne() { return ui->edit1->text(); {To copy to clipboard, switch view to plain text mode
The in the parent you do:
Qt Code:
QDialog myDialogWithEdits; myDialogWithEdits.exec(); //This will call modal and wait until its closes //This will be executed after it closes ui->edit1->setText(myDialogWithEdits.getValueOfEditOne());To copy to clipboard, switch view to plain text mode
Carlos
klenze (23rd November 2011)
Thanks, it works perfect!
Bookmarks