Results 1 to 14 of 14

Thread: "Driver not loaded!"

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2010
    Location
    Salatiga, Indonesia
    Posts
    160
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    11
    Thanked 32 Times in 29 Posts
    Wiki edits
    1

    Default Re: "Driver not loaded!"

    You don't need to add additional library path, just move your sqldrivers directory to your application directory.

  2. #2
    Join Date
    Aug 2008
    Posts
    33
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanked 1 Time in 1 Post

    Default Re: "Driver not loaded!"

    I am sorry, my english is poor and misunderstand "Does the first snippet run before QApplication constructor or after it? "
    the code is after QApplication constructor, the following is the code.

    Qt Code:
    1. #include <QtGui/QApplication>
    2. #include "TDPDataProcess.h"
    3.  
    4. int main(int argc, char *argv[])
    5. {
    6. QApplication a(argc, argv);
    7.  
    8. QStringList pathList=QApplication::libraryPaths();
    9. pathList.append(QDir::current().absolutePath()+"/plugins");
    10. pathList.append(QApplication::applicationDirPath()+"/plugins");
    11. QApplication::setLibraryPaths(pathList);
    12.  
    13. QTextCodec* codec = QTextCodec::codecForLocale();
    14. QTextCodec::setCodecForLocale(codec);
    15. QTextCodec::setCodecForCStrings(codec);
    16. QTextCodec::setCodecForTr(codec);
    17.  
    18. TDPDataProcess w;
    19. w.show();
    20. return a.exec();
    21. }
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: "Driver not loaded!"

    You need to set library paths for QApplication before creating the application object. The methods you need to call are static so they can be called without an object. If you use them after the application object is already created, plugins will not be loaded as they are loaded in the constructor of the application object.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  4. #4
    Join Date
    Aug 2008
    Posts
    33
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanked 1 Time in 1 Post

    Default Re: "Driver not loaded!"

    Quote Originally Posted by wysota View Post
    You need to set library paths for QApplication before creating the application object. The methods you need to call are static so they can be called without an object. If you use them after the application object is already created, plugins will not be loaded as they are loaded in the constructor of the application object.
    Thanks for replying, however, it sames not the case, I had try as you suggested.

    Qt Code:
    1. int main(int argc, char *argv[])
    2. {
    3. QStringList pathList=QApplication::libraryPaths();
    4. pathList.append(QDir::current().absolutePath()+"/plugins");
    5. pathList.append(QApplication::applicationDirPath()+"/plugins");
    6. QApplication::setLibraryPaths(pathList);
    7.  
    8. /*QString szt;
    9. for(int idx=0; idx<pathList.count(); idx++)
    10. szt += pathList.at(idx) + QObject::tr("\n");
    11. QMessageBox::warning(NULL,QObject::tr("Library path"),szt);*/
    12.  
    13. QApplication a(argc, argv);
    14.  
    15. QTextCodec* codec = QTextCodec::codecForLocale();
    16. QTextCodec::setCodecForLocale(codec);
    17. QTextCodec::setCodecForCStrings(codec);
    18. QTextCodec::setCodecForTr(codec);
    19.  
    20. TDPDataProcess w;
    21. w.show();
    22. return a.exec();
    23. }
    To copy to clipboard, switch view to plain text mode 

  5. #5
    Join Date
    Jun 2010
    Location
    Salatiga, Indonesia
    Posts
    160
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    11
    Thanked 32 Times in 29 Posts
    Wiki edits
    1

    Default Re: "Driver not loaded!"

    Btw, you can try to link qsqlodbc plugin staticaly. So you don't need to worry about library path.

  6. #6
    Join Date
    Nov 2007
    Posts
    6
    Qt products
    Qt4
    Platforms
    MacOS X
    Thanked 3 Times in 2 Posts

    Default Re: "Driver not loaded!"

    I had the same problem with Qt4.6 on WinXP.

    I tried addLibraryPath() and setLibraryPaths(). Also tried qt.conf file. Nothing seemingly worked. It will always fallback to %QT_DIR%/plugins directory.

    Last resort, I added QT_PLUGIN_PATH in the system environment variable, copied sqldrivers/ into the root directory of the EXE file, it works!

    I added QT_PLUGIN_PATH with the value . (a dot) to signify look at the current directory.

  7. #7
    Join Date
    Aug 2008
    Posts
    33
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanked 1 Time in 1 Post

    Default Re: "Driver not loaded!"

    Quote Originally Posted by saa7_go View Post
    You don't need to add additional library path, just move your sqldrivers directory to your application directory.
    I had try, It's does not work! and I added some test code to show the library path

    Qt Code:
    1. QStringList pathList=QApplication::libraryPaths();
    2. pathList.append(QDir::current().absolutePath()+"/plugins");
    3. pathList.append(QApplication::applicationDirPath()+"/plugins");
    4. QApplication::setLibraryPaths(pathList);
    5.  
    6. QString szt;
    7. for(int idx=0; idx<pathList.count(); idx++)
    8. szt += pathList.at(idx) + QObject::tr("\n");
    9. QMessageBox::warning(NULL,QObject::tr("Library path"),szt);
    To copy to clipboard, switch view to plain text mode 

    When exec this program on other PC, the dialog shown that the "xxx/plugins" had successfully added as library path.

  8. #8
    Join Date
    Jun 2010
    Location
    Salatiga, Indonesia
    Posts
    160
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    11
    Thanked 32 Times in 29 Posts
    Wiki edits
    1

    Default Re: "Driver not loaded!"

    Quote Originally Posted by bangqianchen View Post
    I had try, It's does not work! and I added some test code to show the library path
    What do you mean it's does not work? The driver is not loaded?

    When you move your sqldrivers directory to your application directory, does your files and direcotory structures look like this:

    E:\TDPDATAPROCESS
    | Microsoft.VC90.CRT.manifest
    | Microsoft.VC90.DebugCRT.manifest
    | msvcm90d.dll
    | msvcp90d.dll
    | msvcr90d.dll
    | QtCored4.dll
    | QtGuid4.dll
    | QtSqld4.dll
    | TDPDataProcess.exe
    | TDPDataProcess.exe.intermediate.manifest
    |
    +---Database
    | DPS_TSDB.mdb
    |
    +---sqldrivers
    | qsqlodbcd4.dll

Similar Threads

  1. Replies: 1
    Last Post: 24th April 2010, 03:43
  2. Replies: 4
    Last Post: 10th November 2009, 19:48
  3. The strange problem:"QSqlDatabase: QMYSQL driver not loaded"
    By osmanthus in forum Installation and Deployment
    Replies: 2
    Last Post: 22nd January 2009, 15:12
  4. The PostgreSQL plugin is not loaded in "SQL Browser" example
    By Scratch in forum Installation and Deployment
    Replies: 1
    Last Post: 18th November 2008, 01:30
  5. Translation QFileDialog standart buttons ("Open"/"Save"/"Cancel")
    By victor.yacovlev in forum Qt Programming
    Replies: 4
    Last Post: 24th January 2008, 19:05

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.