Qt C++ “new” operation may cause unexpected errors?
Qt C++ “new” operation may cause unexpected errors? There are two UIs in my project, namely, Login and MainWindow. Now I use signal-slot method to transfer some data of Login to some MainWindow class member variables,and here is some key code: Login::Login(QWidget *parent) : QDialog(parent) { setupUi(this); MainWindow *w = new MainWindow; connect(this,SIGNAL(sendData(QList<QString>)),w,SLOT(receiveData(QList<QString>))); } //get data from Login void MainWindow::receiveData(QList<QString> userList){ userName = userList.at(0); password = userList.at(1); QSqlQuery query; bool b = query.exec(QString("SELECT * FROM user WHERE user_id = '%1' AND password = '%2'").arg(userName).arg(password)); if(b){ query.first(); userType = query.value(1).toString(); qDebug()<<"user_type:"<<userType; //always has value in userType qDebug()<<"user_id:"<<userN...