[Interest] Unique Database connection name
arno
arno at disconnect.de
Wed Sep 4 18:23:17 CEST 2013
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?
--
Gruß,
Arno.
More information about the Interest
mailing list