problem with QSqlTableModel and unique_ptr ! QTableView has The data but show Nothing
-
Hi ~~ I Have A problem Using unique_ptr
std::unique_ptr<QSqlTableModel> freshModel(new QSqlTableModel(ui->clientstableview_2)); freshModel->setTable("clients"); freshModel->select(); if (!freshModel->select()) { qDebug() << "Error in select:" << freshModel->lastError().text(); } else { qDebug() << "working ~ row count="<<freshModel->rowCount(); } ui->clientstableview_2->setModel(freshModel.get()); qDebug()<<"HeaderData 0 ="<<ui->clientstableview_2->model()->headerData(0,Qt::Horizontal).toString(); // tableView has the data correctly but the TableView Show Nothing ... ~!
is there any solution for that?
-
No, the model is not alive after the unique pointer destroys it...
-
@Proton-Phoenix said in problem with QSqlTableModel and unique_ptr ! QTableView has The data but show Nothing:
is there any solution for that
Don't use a shared pointer or make sure it is alive as long as the tableview.
-
@Christian-Ehrlicher said in problem with QSqlTableModel and unique_ptr ! QTableView has The data but show Nothing:
@Proton-Phoenix said in problem with QSqlTableModel and unique_ptr ! QTableView has The data but show Nothing:
is there any solution for that
Don't use a shared pointer or make sure it is alive as long as the tableview.
Yep i am sure it's alive , debugging data in the QTableView , and it's there without any problem, but it doesn't show those data only empty tableView !@Christian-Ehrlicher
-
No, the model is not alive after the unique pointer destroys it...
-
@Christian-Ehrlicher said in problem with QSqlTableModel and unique_ptr ! QTableView has The data but show Nothing:
ah I understand now , many Thanks bro <3 i will try another solution
really I Appreciate Your PROFESSIONAL Support <3 -