Deleting row from QTableWidget and from Sqlite database
-
@Risver said in Deleting row from QTableWidget and from Sqlite database:
Okay and how can i connect it with the button_clicked signal?
You won't
When you react on the button clicked signal, get the current selection from the view and delete the selected rows in the model.@Christian-Ehrlicher said in Deleting row from QTableWidget and from Sqlite database:
@Risver said in Deleting row from QTableWidget and from Sqlite database:
Okay and how can i connect it with the button_clicked signal?
You won't
When you react on the button clicked signal, get the current selection from the view and delete the selected rows in the model.Something like this ?
void MainWindow::on_remove_clicked() { int selectedRow = ui->tableView->selectionModel()->currentIndex().row(); }
-
@Christian-Ehrlicher said in Deleting row from QTableWidget and from Sqlite database:
@Risver said in Deleting row from QTableWidget and from Sqlite database:
Okay and how can i connect it with the button_clicked signal?
You won't
When you react on the button clicked signal, get the current selection from the view and delete the selected rows in the model.Something like this ?
void MainWindow::on_remove_clicked() { int selectedRow = ui->tableView->selectionModel()->currentIndex().row(); }
@Risver Yes.
-
@Risver Yes.
@Christian-Ehrlicher
Now when i'm trying to implement QSqlTableModel::deleteRowFromTable the debugger says the deleteRowFromTable is a protected member of QSqlTableModel -
@Christian-Ehrlicher
Now when i'm trying to implement QSqlTableModel::deleteRowFromTable the debugger says the deleteRowFromTable is a protected member of QSqlTableModel -
@jsulm
Now i have error - reference to type 'const QModelIndex' could not bind to an rvalue of type 'int'.
I think i have to refer to QModelIndex but i don't know how. I have a QSqlQueryModel. Should i change it to QAbstractTableModel ? -
void MainWindow::on_remove_clicked() { if (ui->tableView->selectionModel()->hasSelection()) { int addressId = ui->tableView->selectionModel()->currentIndex().row(); querymodel->removeRow(addressId, 1); qDebug() << addressId; } }
The QT version is 5.0.2
-
void MainWindow::on_remove_clicked() { if (ui->tableView->selectionModel()->hasSelection()) { int addressId = ui->tableView->selectionModel()->currentIndex().row(); querymodel->removeRow(addressId, 1); qDebug() << addressId; } }
The QT version is 5.0.2
@Risver said in Deleting row from QTableWidget and from Sqlite database:
QT version is 5.0.2
Check the documentation for removeRows() in that Qt version.
Probably it has a different signature.Is there a reason why you're using such an ancient version?
-
@Risver said in Deleting row from QTableWidget and from Sqlite database:
QT version is 5.0.2
Check the documentation for removeRows() in that Qt version.
Probably it has a different signature.Is there a reason why you're using such an ancient version?
-
@jsulm said in Deleting row from QTableWidget and from Sqlite database:
Is there a reason why you're using such an ancient version?
I just installed it a while time ago.
@Risver said in Deleting row from QTableWidget and from Sqlite database:
I just installed it a while time ago.
Before you spend any more time on this. Qt5 is already up to 5.15, unless you have some deep reason for wanting 5.0 I would uninstall and get such an up-to-date version.
-
@Risver said in Deleting row from QTableWidget and from Sqlite database:
I just installed it a while time ago.
Before you spend any more time on this. Qt5 is already up to 5.15, unless you have some deep reason for wanting 5.0 I would uninstall and get such an up-to-date version.
-
@Risver
You can indeed, though my personal preference would be to take the latest Qt5.x release. I still see too many issues with Qt6, not to mention that I think they still have not ported all modules, depends what bits you will be using.However, my learned colleagues may disagree and advise you to go for Qt6, i don't know....
-
@Risver
You can indeed, though my personal preference would be to take the latest Qt5.x release. I still see too many issues with Qt6, not to mention that I think they still have not ported all modules, depends what bits you will be using.However, my learned colleagues may disagree and advise you to go for Qt6, i don't know....
-
@JonB
I'm installing Qt 6 for now, i will check if everything works. If it won't i will install Qt 5.15Okay, I configured the project in the new Qt and i still have the same error.
@Risver said in Deleting row from QTableWidget and from Sqlite database:
I configured the project in the new Qt and i still have the same error.
And you are sure you're building with Qt6 now?
And did you do a complete rebuild? -
@Risver said in Deleting row from QTableWidget and from Sqlite database:
I configured the project in the new Qt and i still have the same error.
And you are sure you're building with Qt6 now?
And did you do a complete rebuild?@jsulm said in Deleting row from QTableWidget and from Sqlite database:
@Risver said in Deleting row from QTableWidget and from Sqlite database:
I configured the project in the new Qt and i still have the same error.
And you are sure you're building with Qt6 now?
And did you do a complete rebuild?Yes i'm sure i building with Qt6,
but i'm not sure how can i complete rebuild the project.
found this. Still have error -
void MainWindow::on_remove_clicked() { if (ui->tableView->selectionModel()->hasSelection()) { int addressId = ui->tableView->selectionModel()->currentIndex().row(); querymodel->removeRow(addressId, 1); qDebug() << addressId; } }
The QT version is 5.0.2
@Risver said in Deleting row from QTableWidget and from Sqlite database:
The QT version is 5.0.2
I'm guessing 5.0.2 is/was your QtCreator version (the IDE) not the version of Qt. Look at the 'Kit' you are using, it will say what version of Qt you are using.
-
-
@Risver said in Deleting row from QTableWidget and from Sqlite database:
The QT version is 5.0.2
I'm guessing 5.0.2 is/was your QtCreator version (the IDE) not the version of Qt. Look at the 'Kit' you are using, it will say what version of Qt you are using.