I am new to qt and I am trying to build a new project with QT. I have a nice GUI built in my login form and everything is compiling great until I try to connect my button to a function using signals and slots.
First I tried to use the QT editor. I would use the slots and signals editor and I couldn't figure out how to get it to my functions in my .cpp then I tried to do it outside of the editor by adding the connect button to my cpp and my header. I can get it to compile but i get an error saying "irst-chance exception at 0x670e98d8 in TheWGE.exe: 0xC0000005: Access violation reading location 0xffffffff.
Unhandled exception at 0x670e98d8 in TheWGE.exe: 0xC0000005: Access violation reading location 0xffffffff. BREAK OR CONTINUE"
this is my thewge.cpp
#include "thewge.h"
#include <QtGui/QApplication>
#include <QSignalMapper>
#include <QPushButton>
TheWGE
::TheWGE(QWidget *parent, Qt
::WFlags flags
){
ui.setupUi(this);
QObject::connect(LoginBtn,
SIGNAL(clicked
()),
this,
SLOT(accept
()));
}
TheWGE::~TheWGE()
{
//delete usrLineEdit;
//delete pwdLineEdit;
}
void TheWGE::readSettings()
{
//Set Focus to the right place
/* if (ui.usrLineEdit->text().trimmed().isEmpty() ) {
ui.usrLineEdit->setFocus();
} else {
ui.pwdLineEdit->setFocus();
} */
}
void TheWGE::accept()
{
//readSettings();
}
#include "thewge.h"
#include <QtGui/QApplication>
#include <QSignalMapper>
#include <QPushButton>
TheWGE::TheWGE(QWidget *parent, Qt::WFlags flags)
: QMainWindow(parent, flags)
{
ui.setupUi(this);
QObject::connect(LoginBtn, SIGNAL(clicked()), this, SLOT(accept()));
}
TheWGE::~TheWGE()
{
//delete usrLineEdit;
//delete pwdLineEdit;
}
void TheWGE::readSettings()
{
//Set Focus to the right place
/* if (ui.usrLineEdit->text().trimmed().isEmpty() ) {
ui.usrLineEdit->setFocus();
} else {
ui.pwdLineEdit->setFocus();
} */
}
void TheWGE::accept()
{
//readSettings();
}
To copy to clipboard, switch view to plain text mode
my thewge.h
#ifndef THEWGE_H
#define THEWGE_H
#include <QtGui/QMainWindow>
#include "ui_thewge.h"
#include <QPixmap>
{
Q_OBJECT
public:
TheWGE
(QWidget *parent
= 0, Qt
::WFlags flags
= 0);
~TheWGE();
private:
Ui::TheWGEClass ui;
public slots:
void accept();
void readSettings();
//QObject::connect(LoginBtn, SIGNAL(clicked()), thewge, SLOT(accept()));
};
#endif // THEWGE_H
#ifndef THEWGE_H
#define THEWGE_H
#include <QtGui/QMainWindow>
#include "ui_thewge.h"
#include <QPixmap>
class TheWGE : public QMainWindow
{
Q_OBJECT
public:
TheWGE(QWidget *parent = 0, Qt::WFlags flags = 0);
~TheWGE();
private:
Ui::TheWGEClass ui;
QLineEdit* usrLineEdit;
QLineEdit* pwdLineEdit;
QPushButton* LoginBtn;
public slots:
void accept();
void readSettings();
//QObject::connect(LoginBtn, SIGNAL(clicked()), thewge, SLOT(accept()));
};
#endif // THEWGE_H
To copy to clipboard, switch view to plain text mode
Bookmarks