On 2013-09-04 10:23, arno wrote:
> Hello all, > > Problem: > Generate a unique database connection name for a connection in a Thread > (QRunnable). I'm trying to do this (pseudo code): > > class LongRunning : public QObject, public QRunnable { > Q_OBJECT > explicit LongRunning(); > > protected: > virtual void run() > } > > void LongRunning::run() { > //mydb is set up in a singleton > QSqlDatabase db = QSqlDatabase::cloneDatabase("mydb", uniquesting); > ... select something from database... > End of LongRunning: > QSqlDatabase::removeDatabase(uniquestring); > } > > LongRunning is managed by a QThreadPool. I'm looking for a way to > generate a unique "uniquestring" for each connection. > > I tried QString::number(qint64(this)) as "uniqestring", but of course it > doesn't work, because "this" is reused by QThreadPool, and it's so ugly > that it hurts the eye. > > I tried QUuid, but the documentation is scarce. Seems it's only a class > for representing a UUID, not for generating one, right? > > Anything obvious I missed? Any chance you can use a default connection for the application rather than create an connection in each thread? Karl
_______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest