Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Steps of how to build QPSQL driver on linux(ubuntu 14.04)?
QtWS25 Last Chance

Steps of how to build QPSQL driver on linux(ubuntu 14.04)?

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 3 Posters 7.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vIJI
    wrote on last edited by
    #1

    Hi,
    i'm newbie to Qt...i wanted to interface Qt with postgresql database.....i tried with this following code but failed to do that...Any help is appreciated..

    QSqlDatabase mydb;
    mydb.addDatabase("QPSQL");
    mydb.setHostName("192.168.2.24");
    mydb.setDatabaseName("conf");
    mydb.setUserName("postgres");
    mydb.setPassword("cdt321");
    mydb.setPort(5432);
    mydb.setConnectOptions();
    
    if(mydb.open())
    {
        qDebug() << "opened!";
    }
    else
    {
        qDebug() << mydb.lastError();
    }
    

    After Execution....

    I'm left with the Error message as follows

    Starting /run/user/0/gvfs/smb-share:server=main,share=data/Vijay/tableWidget/tableWidget...
    QSqlDatabase: QPSQL driver not loaded
    QSqlDatabase: available drivers: QSQLITE
    QSqlError(-1, "Driver not loaded", "Driver not loaded")
    ("QSQLITE")

    How to build QPSQL driver ...i tried with many ways but failed ...can anybody help me with the steps..

    1 Reply Last reply
    0
    • mrdebugM Offline
      mrdebugM Offline
      mrdebug
      wrote on last edited by
      #2

      Have you build Qt from source?
      Are you sure to have libpq5 and libpq-dev installed?

      Need programmers to hire?
      www.labcsp.com
      www.denisgottardello.it
      GMT+1
      Skype: mrdebug

      1 Reply Last reply
      0
      • V Offline
        V Offline
        vIJI
        wrote on last edited by
        #3

        Yes, i do have libpq and libpd-dev files......and whats Qt installed from source?
        Will you please brief about that?

        Thank you for the reply.

        1 Reply Last reply
        0
        • TheBadgerT Offline
          TheBadgerT Offline
          TheBadger
          wrote on last edited by TheBadger
          #4

          The following steps should get you going, you need the Qt sources (if you use the online installer just run it and also download the sources for the Qt version that you have already installed)

          PS: You do not need to build Qt from source, but you need the sources to build the plugin.

          $ sudo apt-get install libpq-dev
          $ cd $QTDIR/<version>/Src/qtbase/src/plugins/sqldrivers/psql
          $ qmake "INCLUDEPATH+=/usr/include/postgresql" "LIBS+=-L/usr/lib -lpq" psql.pro
          $ make
          $ make install
          

          After that is done check that the libqsqlpsql.so library is located in $QTDIR/<version>/gcc_64/plugins/sqldrivers/

          That should be it.


          Check out my SpellChecker Plugin for Qt Creator @ https://github.com/CJCombrink/SpellChecker-Plugin

          1 Reply Last reply
          0
          • V Offline
            V Offline
            vIJI
            wrote on last edited by
            #5

            After running cd $QTDIR/3.0.1/Src/qtbase/src/plugins/sqldrivers/psql
            its showing no such file or directory....

            and i think in dont have qtbase file..

            TheBadgerT 1 Reply Last reply
            0
            • V vIJI

              After running cd $QTDIR/3.0.1/Src/qtbase/src/plugins/sqldrivers/psql
              its showing no such file or directory....

              and i think in dont have qtbase file..

              TheBadgerT Offline
              TheBadgerT Offline
              TheBadger
              wrote on last edited by
              #6

              @vIJI
              You need to replace the $QTDIR with your actual path to Qt, so you end up with something like: /opt/Qt/5.4/Src/qtbase/src/plugins/sqldrivers/psql

              Also I am pretty sure that you should not have version 3.0.1 of Qt, that might be your version of QtCreator (not the same).

              Make sure where Qt was installed and what version of Qt you have.

              Perhaps run the following to see what version is installed:
              qmake --version


              Check out my SpellChecker Plugin for Qt Creator @ https://github.com/CJCombrink/SpellChecker-Plugin

              1 Reply Last reply
              0
              • mrdebugM Offline
                mrdebugM Offline
                mrdebug
                wrote on last edited by
                #7

                This situation is a little bit strange.
                I normally use PostgreSql with Qt (WIndows, Linux, Mac) without any problem.
                In the Linux machine I only need the libpq5 and libpq-dev, and the Qt plugins directory.

                Need programmers to hire?
                www.labcsp.com
                www.denisgottardello.it
                GMT+1
                Skype: mrdebug

                TheBadgerT 1 Reply Last reply
                0
                • mrdebugM mrdebug

                  This situation is a little bit strange.
                  I normally use PostgreSql with Qt (WIndows, Linux, Mac) without any problem.
                  In the Linux machine I only need the libpq5 and libpq-dev, and the Qt plugins directory.

                  TheBadgerT Offline
                  TheBadgerT Offline
                  TheBadger
                  wrote on last edited by
                  #8

                  @mrdebug
                  I always need to build the plugin myself.

                  Do you install or build Qt yourself? Perhaps if you build it it detects that the pq libs are available and built the plugin automatically during the process.


                  Check out my SpellChecker Plugin for Qt Creator @ https://github.com/CJCombrink/SpellChecker-Plugin

                  1 Reply Last reply
                  0
                  • mrdebugM Offline
                    mrdebugM Offline
                    mrdebug
                    wrote on last edited by
                    #9

                    Only in arm, in i386 I use the Qt official pachage.
                    Maybe the problem is the qt.conf file. Maybe the plugins directory is not in the correct position.

                    Need programmers to hire?
                    www.labcsp.com
                    www.denisgottardello.it
                    GMT+1
                    Skype: mrdebug

                    1 Reply Last reply
                    0

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved