Hi everybody..
I have for examples 2 classes (2 Dialogs). My example send a text from a dialog to the other one. It Works.
But my Question is if my way are correct? Can somebody show me how the professional way works and what is not ok on my example?
my function sendString() are sending a text to the other dialog..

Thanks forwading

main.cpp
Qt Code:
  1. //Vorlage für Dialoge
  2.  
  3. //Klassen:
  4. #include "mydialog.h"
  5. #include <QApplication>
  6.  
  7.  
  8. int main(int argc, char *argv[])
  9. {
  10. QApplication app(argc, argv);
  11. MyDialog mydialog;
  12.  
  13. mydialog.show();
  14. return app.exec();
  15. }
To copy to clipboard, switch view to plain text mode 

mydialog.h
Qt Code:
  1. #include "ui_dialog.h"
  2.  
  3.  
  4. //My Dialog ist eine Vererbte Klasse von UI_Dialog
  5. class MyDialog : public QDialog
  6. {
  7. Q_OBJECT
  8.  
  9. public:
  10. MyDialog(QWidget *parent = 0);
  11. Ui::Dialog ui;
  12.  
  13. //Funktionen
  14. public slots:
  15. void showMessage();
  16. void showDialogSuchen();
  17.  
  18.  
  19. private:
  20. //Ui::<Name des Objekts, siehe Designer> ui
  21.  
  22.  
  23. };
To copy to clipboard, switch view to plain text mode 

mydialog.cpp
Qt Code:
  1. //Klassen:
  2. #include "mydialog.h"
  3. #include "dialogsuchen.h"
  4. #include <QMessageBox>
  5.  
  6. //Konstruktor
  7. MyDialog::MyDialog(QWidget *parent)
  8. : QDialog(parent)
  9. {
  10. ui.setupUi(this);
  11.  
  12. connect(ui.okButton, SIGNAL(clicked()), this, SLOT(showMessage()));
  13. connect(ui.cancelButton, SIGNAL(clicked()), this, SLOT(close()));
  14. connect(ui.openButton, SIGNAL(clicked()), this, SLOT(showDialogSuchen()));
  15. }
  16.  
  17. //Diese Funktion zeigt eine MessageBox an
  18. void MyDialog::showMessage()
  19. {
  20. QMessageBox::information(this, "Application name",
  21. "Hallo Welt\n"
  22. "Tutorial 1");
  23. }
  24. void MyDialog::showDialogSuchen()
  25. {
  26. DialogSuchen dialogsuchen(this);
  27. dialogsuchen.exec();
  28.  
  29. }
To copy to clipboard, switch view to plain text mode 

dialogsuchen.h
Qt Code:
  1. #include "ui_dialogsuchen.h"
  2.  
  3.  
  4. //My Dialog ist eine Vererbte Klasse von UI_Dialog
  5. class DialogSuchen : public QDialog
  6. {
  7. Q_OBJECT
  8.  
  9. public:
  10. DialogSuchen(QWidget *parent = 0);
  11.  
  12. //Funktionen
  13. public slots:
  14. void showMessage();
  15. void sendString();
  16.  
  17.  
  18. private:
  19. //Ui::<Name des Objekts, siehe Designer> ui
  20. Ui::DialogSuchen ui;
  21.  
  22. };
To copy to clipboard, switch view to plain text mode 

dialogsuchen.cpp
Qt Code:
  1. //Klassen:
  2. #include "dialogsuchen.h"
  3. #include "mydialog.h"
  4. #include <QMessageBox>
  5.  
  6. //Konstruktor
  7. DialogSuchen::DialogSuchen(QWidget *parent)
  8. : QDialog(parent)
  9. {
  10. ui.setupUi(this);
  11.  
  12. connect(ui.okButton, SIGNAL(clicked()), this, SLOT(showMessage()));
  13. connect(ui.cancelButton, SIGNAL(clicked()), this, SLOT(close()));
  14. connect(ui.sendButton, SIGNAL(clicked()), this, SLOT(sendString()));
  15.  
  16. }
  17.  
  18. //Diese Funktion zeigt eine MessageBox an
  19. void DialogSuchen::showMessage()
  20. {
  21. QMessageBox::information(this, "Application name",
  22. "Hallo Welt\n"
  23. "Tutorial 1");
  24. }
  25. void DialogSuchen::sendString()
  26. {
  27. MyDialog *mydialog = qobject_cast<MyDialog*>(parent());
  28. QString text = ui.lineEdit->text();
  29.  
  30. mydialog->ui.textEdit->setPlainText(text);
  31.  
  32.  
  33. }
To copy to clipboard, switch view to plain text mode