[Qt-interest] using an application's databse connection inside aDLL (on win32)

Adolf Markus Berthold berthold at organet.com
Fri Mar 6 10:58:41 CET 2009


Scott Aron Bloom wrote:

> What have you tried? I have used a "setDatabase" function into a DLL and
> it worked..

I already plan to implement such a "setDatabase" function as well, but only
as a last resort.

>  However, I have not tried to use the "global" database, but
> I would guess it would work...
> Have you tried it? What happened? 

In the concerning DLL, the qt-internal list ob named database connections
(QSqlDatabase::connectionNames()) is always empty and QSqlDatabase::database()
always returns an invalid database, no matter how many
connections got opened and registered in the main application. I guess that
on windows a DLL has its own personal protected memory region and therefore
cannot access the main application's global objects, such a that global
database connections list. But I mainly work with linux and do not have
enough knowledge of windows internals to estimate this. If I am right,
then this would render that qt-named-connections paradigm unusable from
inside a DLL. On the other hand, the code of QSqlDatabase does itself reside
in a DLL.

-- 

greetings ... Adolf Berthold





More information about the Qt-interest-old mailing list