[Qt-interest] questions about QODBC

Bill King bill.king at nokia.com
Wed Sep 9 05:04:09 CEST 2009


On 09/09/2009 12:55 PM, ext yanqzhi at gmail.com wrote:
> hi,everyone :
>
> I am writing a test progranm about QODBC using Qt 4.5. When the
> progranm run in a coumputer on which Qt is not installed,"Driver not
> loaded" was displayed.I have tried methods what I could found, but I
> could not solved it.
>
> I tried dll:
> 1.I placed the qsqlodbc4.dll in my application's directory(app) .
> 2.I placed the qsqlodbc4.dll in app/plugins.
> 3.I placed the qsqlodbc4.dll in app/sqldrivers.
> 4.I placed the qsqlodbc4.dll in app/plugins/sqldrivers.
The fourth one should be correct.
That "driver not loaded" is usually because the driver dll failed to
load for some reason, try running your application after setting the
environment variable QT_DEBUG_PLUGINS=1
It may give you a bit of information on why it's not loading.
>
> I tried lib
> Add Q_IMPORT_PLUGIN(qsqlodbc) in code
> Add QTPLUGIN += qsqlodbc in .pro
> but when I compiled the program, "undefined reference to
> 'qt_plugin_instance_qsqlodbc()'" was displayed.
>
> I tried QPluginLoader
> QString str = QApplication::applicationDirPath() + QDir::separator() +
> "plugins";
> QDir dir = QDir( QApplication::applicationDirPath() +
> QDir::separator() + "plugins");
> foreach (QString fileName, dir.entryList(QDir::Files))
> {
> QPluginLoader loader(dir.absoluteFilePath(fileName));
> QObject *plugin = loader.instance();
> if (plugin)
> {
> int n = 0;
> }
> }
> when I debuged the progarm,
> bool QPluginLoader::load()
> {
> if (!d || d->fileName.isEmpty())
> return false;
> if (did_load)
> return d->pHnd && d->instance;
> if (!d->isPlugin())
> return false;
> did_load = true;
> return d->loadPlugin();
> }
> at below row return false (qsqlodbc.dll was loaded)
> if (!d->isPlugin())
> return false;
>
> best regards
>
>
>         
>  


-- 
Bill King, Software Engineer
Qt Development Frameworks, Nokia Pty Ltd
Brisbane Office

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090909/468426ed/attachment.html 


More information about the Qt-interest-old mailing list