QDialog window usage and exemples...
-
you need to use Open instead Exec, but wanna get result code. It's a principle question.
Isn't it?
-
thanks Andre, yur explication is ok for me.
Also, i try it an ok... the QDialog window open fine.BUT, i have always the same problem crash application (really strange).
This not resolve the problem, but maybe it is a way for understand, because...
because when i call, inside these QDialog windows (like from every where) the QSqlQuery query, i do a query.exec().
Also, i see inside debug tool that it crash on sql driver use...
So maybe it is the same problem... of bad call.what do you think ?
is it possible to use same technic for call a query than for call a QDialog or everythings ?(again, thanks for your answer, i learn really a lot with you)
-
get the source code
how you declare the query and execute it ? -
in fact someone make me understand that there is no way to do same style for execute query.
For use QSqlQuery, i go by declare the database default access, and then declare a QSqlQuery. After, i use query.prepare(), and if need, query.bindValue(). after that, i do an query.exec() around condition for get back an eventuall error, and then a loop while(query.next()) for catch the datas.but also, in the first QDialog window, i use a QSqlQueryModel and use model->setQuery("SELECT...blablabla...");
i think that there is an internal conflict because debug gdb tell me that it crash on the postgresql drivers qsl library.
so... i try to find a solution...
-
maybe the solution is to not use QSqlQueryModel... but pfffff... i'm lazy and this tool is nice and if it will be impossible to trust the Qt tools and do all without model helper... why follow to use Qt and not just use WXWidget in fact ?
I just follow the exemples and this crash is really strange. In fact, i hope it is an error from my-self.
I hope also to find a solution without re-invent the wheel or have to big difficulties.
-
And you think that switching toolkit would solve SQL driver issues for you?
-
Subst27, thank you a lot for give some time for try to help.
Also, i give you some parts of my code.
like that you could have a look and see if there is something you like or dislike, or maybe could use for yourself, and maybe find a bad code.
this code is not clean... but some parts are considered as finished inside. -
Andre: i really don't know. i don't know because i can not understand why this issue occur.
If i caould be able to understand what's happen really, i will sure find a good solution (and maybe tuch the code of the driver). But i think this is not my level.I just try to understand at this step of my reflexion... and then, i see that when i call this from an other one QDialog window who not use QSqlQueryModel, there is no problem... so i think that maybe there is a problem inside the code of the QSqlQueryModel tool... but i'm really not sure, i just do a link by deduction.
-
for the part of code... this part of my open_project::on_projects_list_clicked() file has to be change by this:
@
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();
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));
if (id != 0)
locations_refresh();
ui_open_project->treeView_locations->setColumnHidden(1,true);
}
@ -
ok Andre, now i swith toolkit and not use QsqlQueryModel for popaulate my model for my QListView of the QDialog window who call the other...
And YES... this was the problem definitly.So... use QSqlQueryModel without some other use of query could crash the application. I had a good dedustive analyse of the problem. Impossible to use this tool, this tool is not "good" (execpt if you only use one QDialog maybe) and bugged.
But... what i can do for post a bug around this tool for Qt ?
Wich post could be positive bug report for help to find a solution for this tool can works good ? -
here is the modification of my code for be able to see the application works normally...
https://gist.github.com/anonymous/09985ba94fa765754193
if someone find why this QSqlQueryModel crash the application, and/or what kind of bug publication i can write, you would be welcome to teach this.
thank you for your help and teach.
-
forget my text about QStandardItem, i was wrong.
But not for crash by QSqlQUeryModel use with some other QSqlQuery at same time ith other QDialog window open. I follox my search around this for try to use it well... if possible.
I hope one day to grow up my level of C++ for repair the bugged Qt code. I try to have a look inside qsql postgresql driver... but the code is really strange, i can not undersatnd well what the hacker does and why.
-
well..
I'v been awaynow coming back