Qt-interest Archive, May 2008
[4.4.0] How to make a QSqlQueryModel requery?
Message 1 in thread
Hi,
I am using a QSqlQueryModel to display some data from a database. However,
during the display, this data is being modified. I would like the
modifications to be reflected in my view. For that, I would probably need to
trigger some kind of requerying of the data. I have made that happen using
the following code:"
QString modelQuery = m_listModel->query().lastQuery();
m_listModel->setQuery("");
m_listModel->setQuery(modelQuery, QSqlDatabase::database("bibtechmondb"));However, I would expect that it is possible to do this in a more elegant
way, without reading and writing the query itself. I must be overlooking
some conveneant slot or something like that.
Any thoughts?
André
--
[ signature omitted ]
Message 2 in thread
André wrote:
> Hi,
>
> I am using a QSqlQueryModel to display some data from a
> database. However,
> during the display, this data is being modified. I would like the
> modifications to be reflected in my view. For that, I would
> probably need to
> trigger some kind of requerying of the data. I have made that
> happen using
> the following code:"
>
> QString modelQuery = m_listModel->query().lastQuery();
> m_listModel->setQuery("");
> m_listModel->setQuery(modelQuery,
> QSqlDatabase::database("bibtechmondb"));However, I would
> expect that it is possible to do this in a more elegant
> way, without reading and writing the query itself. I must be
> overlooking
> some conveneant slot or something like that.
>
> Any thoughts?
>
> André
Hi André,
Try query().result()->exec()
Regards,
Tony Rietwyk
--
[ signature omitted ]