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!
#ifndef REMOTECONNECTION_H
#define REMOTECONNECTION_H
#include <QtGui/QDialog>
#include "ui_remoteconnection.h"
namespace Ui {
class RemoteConnection;
}
class RemoteConnection
: public QDialog { Q_OBJECT
Q_DISABLE_COPY(RemoteConnection)
public:
explicit RemoteConnection
(QWidget *parent
= 0);
virtual ~RemoteConnection();
protected:
virtual void changeEvent
(QEvent *e
);
private:
Ui::RemoteConnection *m_ui;
public slots:
void connecting();
};
#endif // REMOTECONNECTION_H
#include "remoteconnection.h"
#include "ui_remoteconnection.h"
RemoteConnection
::RemoteConnection(QWidget *parent
) : m_ui(new Ui::RemoteConnection)
{
m_ui->setupUi(this);
m_ui->connectionStatus->setText("Not Connected"); // THIS DISPLAYS OK
connect(m_ui->pbConnect, SIGNAL(clicked()), this, SLOT(connecting()));
}
RemoteConnection::~RemoteConnection()
{
delete m_ui;
}
void RemoteConnection::connecting()
{
Ui_RemoteConnection rc;
rc.connectionStatus->setText("Trying"); // CRASHES HERE WHEN CONNECT BUTTON IS PUSHED
}
void RemoteConnection
::changeEvent(QEvent *e
) {
switch (e->type()) {
m_ui->retranslateUi(this);
break;
default:
break;
}
}
#ifndef REMOTECONNECTION_H
#define REMOTECONNECTION_H
#include <QtGui/QDialog>
#include "ui_remoteconnection.h"
namespace Ui {
class RemoteConnection;
}
class RemoteConnection : public QDialog {
Q_OBJECT
Q_DISABLE_COPY(RemoteConnection)
public:
explicit RemoteConnection(QWidget *parent = 0);
virtual ~RemoteConnection();
protected:
virtual void changeEvent(QEvent *e);
private:
Ui::RemoteConnection *m_ui;
public slots:
void connecting();
};
#endif // REMOTECONNECTION_H
#include "remoteconnection.h"
#include "ui_remoteconnection.h"
RemoteConnection::RemoteConnection(QWidget *parent) :
QDialog(parent),
m_ui(new Ui::RemoteConnection)
{
m_ui->setupUi(this);
m_ui->connectionStatus->setText("Not Connected"); // THIS DISPLAYS OK
connect(m_ui->pbConnect, SIGNAL(clicked()), this, SLOT(connecting()));
}
RemoteConnection::~RemoteConnection()
{
delete m_ui;
}
void RemoteConnection::connecting()
{
Ui_RemoteConnection rc;
rc.connectionStatus->setText("Trying"); // CRASHES HERE WHEN CONNECT BUTTON IS PUSHED
}
void RemoteConnection::changeEvent(QEvent *e)
{
QDialog::changeEvent(e);
switch (e->type()) {
case QEvent::LanguageChange:
m_ui->retranslateUi(this);
break;
default:
break;
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks