This is probably very simple to solve but since I am a newbie to both C++ and QT, I just can't see it. main shows the remoteconnection form on startup and the text "Not Connected" displays in the line edit connectionStatus, no problem. When you push the button pbConnect which calls connecting() and tries to change the text, the application crashes.

Any help is appreciated!

Qt Code:
  1. #ifndef REMOTECONNECTION_H
  2. #define REMOTECONNECTION_H
  3.  
  4. #include <QtGui/QDialog>
  5. #include "ui_remoteconnection.h"
  6.  
  7. namespace Ui {
  8. class RemoteConnection;
  9. }
  10.  
  11. class RemoteConnection : public QDialog {
  12. Q_OBJECT
  13. Q_DISABLE_COPY(RemoteConnection)
  14. public:
  15. explicit RemoteConnection(QWidget *parent = 0);
  16. virtual ~RemoteConnection();
  17.  
  18. protected:
  19. virtual void changeEvent(QEvent *e);
  20.  
  21. private:
  22. Ui::RemoteConnection *m_ui;
  23.  
  24. public slots:
  25. void connecting();
  26. };
  27.  
  28. #endif // REMOTECONNECTION_H
  29.  
  30.  
  31. #include "remoteconnection.h"
  32. #include "ui_remoteconnection.h"
  33.  
  34. RemoteConnection::RemoteConnection(QWidget *parent) :
  35. QDialog(parent),
  36. m_ui(new Ui::RemoteConnection)
  37. {
  38. m_ui->setupUi(this);
  39. m_ui->connectionStatus->setText("Not Connected"); // THIS DISPLAYS OK
  40.  
  41. connect(m_ui->pbConnect, SIGNAL(clicked()), this, SLOT(connecting()));
  42.  
  43. }
  44.  
  45. RemoteConnection::~RemoteConnection()
  46. {
  47. delete m_ui;
  48. }
  49.  
  50. void RemoteConnection::connecting()
  51. {
  52. Ui_RemoteConnection rc;
  53. rc.connectionStatus->setText("Trying"); // CRASHES HERE WHEN CONNECT BUTTON IS PUSHED
  54. }
  55.  
  56. void RemoteConnection::changeEvent(QEvent *e)
  57. {
  58. QDialog::changeEvent(e);
  59. switch (e->type()) {
  60. case QEvent::LanguageChange:
  61. m_ui->retranslateUi(this);
  62. break;
  63. default:
  64. break;
  65. }
  66. }
To copy to clipboard, switch view to plain text mode