void ControlWin::on_tree_ClippingPlanes_itemClicked(QTreeWidgetItem *item, int column)
{
dialog_EditingTheClippingPlane* dl_EditingTheClippingPlane = new dialog_EditingTheClippingPlane();
dl_EditingTheClippingPlane->SetDate(
"0",
"0",
"0",
"Name");
if(dl_EditingTheClippingPlane.exec() == ...)
{
//...
}
delete dl_EditingTheClippingPlane;
}
В чем проблема?
if(dl_EditingTheClippingPlane.exec())
Shows the dialog as a modal dialog, blocking until the user closes it. The function returns a DialogCode result.
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE", "memdb");
db.setDatabaseName(":memory:");
if (!db.open())
{
qDebug() << db.lastError().text();
// std::exit(1);
}
QSqlQuery q("", db);
q.exec("create table Universities (id integer primary key, Location varchar, Population integer)");
q.exec("insert into Universities values (0, 'MSK', 12000000)");
q.exec("insert into Universities values (1, 'NSK', 1600000)");
q.exec("insert into Universities values (2, 'SPB', 6000000)");
q.exec("insert into Universities values (3, 'PRM', 1000000)");
int sz = ui->tableWidget->rowCount();
QString queryString = "SELECT * FROM Universities WHERE Location IN (";
for(int i = 0; i < sz; ++i)
{
queryString += "?,";
}
queryString.back() = ')';
QSqlQuery query(queryString, db);
for(int i = 0; i < sz; ++i)
{
query.bindValue(i, ui->tableWidget->item(i, 0)->text());
}
if (!query.exec())
{
qDebug() << query.lastError().text();
// std::exit(1);
}
while(query.next())
{
qDebug() << query.value(0).toInt() << " "
<< query.value(1).toString() << " "
<< query.value(2).toInt() << "\n";
}
QSqlQuery query;
query.prepare("SELECT * FROM Universities WHERE Location IN (?)");
int sz = ui->tableWidget->rowCount();
QVariantList values;
for(int i = 0; i < sz; ++i)
{
values << ui->tableWidget->item(i, 0)->text();
}
query.addBindValue(values);
if (!query.execBatch())
{
qDebug() << query.lastError();
}
необходимо по двойному клику на запись удалять её из tableWidget
int i = ui->tableWidget->selectionModel()->currentIndex().row();
ui->tableWidget->removeRow(i);