Created
January 13, 2015 11:16
-
-
Save anonymous/09985ba94fa765754193 to your computer and use it in GitHub Desktop.
modification for not see the application crash when close the QDialog window call by pushButton from this open_project...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// i commented the line use QSqlQueryModel and byu this way, no more crash of the application... but impossible to use QSqlQueryModel and open an other one Qdialog wondow from here (and who use QSqlQuery) without crash if use this QSqlQUeryModel... why ? | |
open_project::open_project(QWidget *parent) : | |
QDialog(parent), | |
ui_open_project(new Ui::open_project) | |
{ | |
ui_open_project->setupUi(this); | |
locations_name = new QStandardItemModel; | |
user->initdb(); | |
locations_refresh(); | |
// model = new QSqlQueryModel(); | |
// model->setQuery("SELECT id, name, comment, refproject, datecreate " | |
// "FROM \"Projects\" " | |
// "WHERE dateclose IS NULL " | |
// "ORDER BY datecreate ;"); | |
model = new QStandardItemModel; | |
QSqlQuery query(user->currentDB()); | |
query.prepare("SELECT id, name, comment, refproject, datecreate " | |
"FROM \"Projects\" " | |
"WHERE dateclose IS NULL " | |
"ORDER BY datecreate ;"); | |
query.exec(); | |
QList<QStandardItem*> my_row; | |
QString sformat = QString("dd/MM/yyyy %1 hh:mm:ss").arg(tr("à")); | |
while(query.next()) { | |
my_row.clear(); | |
QStandardItem *c_id = new QStandardItem(query.value(0).toString()); | |
QStandardItem *c_name = new QStandardItem(query.value(1).toString()); | |
QStandardItem *c_comment = new QStandardItem(query.value(2).toString()); | |
QStandardItem *c_ref_project = new QStandardItem(query.value(3).toString()); | |
QStandardItem *c_date = new QStandardItem(query.value(4).toDateTime().toString(sformat)); | |
my_row << c_name << c_comment << c_ref_project << c_date << c_id; | |
model->appendRow(my_row); | |
} | |
ui_open_project->projects_list->setModel(model); | |
// ui_open_project->projects_list->setModelColumn(1); | |
ui_open_project->projects_list->show(); | |
ui_open_project->checkBox_location->setChecked(false); | |
ui_open_project->treeView_locations->setEnabled(false); | |
ui_open_project->pushButton_location->setEnabled(false); | |
ui_open_project->checkBox_structure->setChecked(false); | |
ui_open_project->treeView_structures->setEnabled(false); | |
ui_open_project->pushButton_structure->setEnabled(false); | |
ui_open_project->treeView_locations->setModel(locations_name); | |
ui_open_project->treeView_locations->setHeaderHidden(true); | |
} | |
open_project::~open_project() | |
{ | |
delete ui_open_project; | |
} | |
void open_project::on_projects_list_clicked(const QModelIndex &index) | |
{ | |
// QString sformat = QString("dd/MM/yyyy %1 hh:mm:ss").arg(tr("à")); | |
// name = model->record(index.row()).value("name").toString(); | |
// comment = model->record(index.row()).value("comment").toString(); | |
// ref_project = model->record(index.row()).value("refproject").toString(); | |
// date_create = model->record(index.row()).value("datecreate").toDateTime(); | |
// id = model->record(index.row()).value("id").toInt(); | |
name = model->data(index).toString(); | |
comment = model->data(model->index(index.row(), 1, index.parent())).toString(); | |
ref_project = model->data(model->index(index.row(), 2, index.parent())).toString(); | |
date_create = model->data(model->index(index.row(), 3, index.parent())).toString(); | |
id = model->data(model->index(index.row(), 4, index.parent())).toInt(); | |
QMessageBox::warning(this, "DEBUG", QString("%1").arg(id)); | |
ui_open_project->label_name->setText(name); | |
ui_open_project->comment->setText(comment); | |
ui_open_project->ref_client->setText(ref_project); | |
// ui_open_project->date_create->setText(date_create.toString(sformat)); | |
ui_open_project->date_create->setText(date_create); | |
if (id != 0) | |
locations_refresh(); | |
ui_open_project->treeView_locations->setColumnHidden(1,true); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment