[solved] SIGSEGV segmentation fault
-
login.cpp:
@#include "login.h"
#include "ui_login.h"login::login(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::login)
{
ui->setupUi(this);
QPixmap pic("C:/Users/asma/Desktop/mychat/client/login.png");
ui->label_4->setPixmap(pic);if(!connOpen()) ui->label_3->setText("failed to open database"); else ui->label_3->setText("Connected");
}
login::~login()
{
delete ui;
}void login::on_pushButton_clicked()
{
QString username, password;
username = ui->lineEdit_username->text();
password = ui->lineEdit_password->text();if(!connOpen()) { qDebug()<<"failed to open database"; return; } connOpen(); QSqlQuery qry; //qry.prepare("select * from users where pseudo = '"+username+"' and mot_de_passe = '"+password+"'"); qry.prepare("select * from users where pseudo = :username and mot_de_passe = :password"); qry.bindValue(":username",username); qry.bindValue(":password",password); if (qry.exec()) { int count=0; while(qry.next()) { count++; } if(count==1) { ui->label_3->setText("username and password are correct"); connClose(); this->hide(); client c; c.setModal(true); c.exec(); } if(count<1) { ui->label_3->setText("username and password incorrect , veuillez s'inscrir"); connClose(); this->hide(); inscription Inscription; Inscription.setModal(true); Inscription.exec(); } } else qDebug()<< qry.lastError();
}
void login::on_pushButton_2_clicked()
{
this->hide();
inscription Inscription;
Inscription.setModal(true);
Inscription.exec();
}
@ -
Hi,
As far as I know this error could be caused due to accessing a NULL POINTER of invalid memory. -
Hi,
As far as I know this error could be caused due to accessing a NULL POINTER or invalid memory. -
Hi,
From the code you posted, neither serveurIP nor serveurPort are initialized
-
Then, the calls should be
@socket->connectToHost(ui->serveurIP->text(), ui->serveurPort->value());@
-
So what was the problem ?
Since you solved it, please update the thread title prepending [solved] so other forum users may know a solution has been found :)
-
What is strange is that this would compile, so I guess you have member variables with these names in your class ? If so remove you should remove them