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. [SOLVED]Postgres Driver on Ubuntu
Forum Updated to NodeBB v4.3 + New Features

[SOLVED]Postgres Driver on Ubuntu

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 1.8k Views 1 Watching
  • 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.
  • B Offline
    B Offline
    Brochadinho
    wrote on last edited by
    #1

    hi all

    I already readed docs on the forum. But nothing works until now.
    @ QSqlDatabase *db = new QSqlDatabase();
    db->addDatabase("QPSQL");
    qDebug()<<db->driverName();
    qDebug()<<db->drivers();
    db->setHostName("localhost");
    db->setDatabaseName("mydb");
    db->setUserName("brochadinho");
    db->setPassword("12345");
    qDebug() << qApp->libraryPaths();
    bool ok = db->open("brochadinho","12345");
    if(ok==true){
    qDebug()<<"sucesso a ligar a base de dados de teste";
    }else{
    qWarning()<<"Erro"<<db->lastError().text();
    }@
    output
    @("QSQLITE", "QMYSQL", "QMYSQL3", "QPSQL", "QPSQL7")
    ("/home/brochadinho/Qt/5.3/gcc_64/plugins", "/home/brochadinho/build-projectoEFactura-Desktop_Qt_5_3_GCC_64bit-Debug")
    Erro: "Driver not loaded Driver not loaded"@

    and then i tried to compile the driver and...

    @brochadinho@luispc:~/Qt/5.3/Src/qtbase/src/plugins/sqldrivers/psql$ qmake "INCLUDEPATH+=/usr/include/postgresql" "LIBS+=-L/usr/lib -lpq" psql.pro
    WARNING: /home/brochadinho/Qt/5.3/Src/qtbase/src/plugins/sqldrivers/qsqldriverbase.pri:4: Unable to find file for inclusion qt_plugin
    Project MESSAGE: Warning: unknown QT: core-private
    Project MESSAGE: Warning: unknown QT: sql-private
    @

    i have Qt Creator 3.2.2 (opensource) Based on Qt 5.3.2 (GCC 4.6.1, 64 bit) on a ubuntu 14.04 LTS 64bit. the postgres was installed via apt-get postegres.

    Any sugestion how to put this working? at have been struglling with this, for 2 days.

    thanks for all the help.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Are you sure that the qmake you are calling is the one from Qt 5.3 ? Also, from what I read, you already have the plugin built. You should run ldd on the original plugin to see if you have a missing dependency.

      Hope it helps

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • B Offline
        B Offline
        Brochadinho
        wrote on last edited by
        #3

        Hi thanks for the reply.

        U are right about the qmake thing.But something real weird is happening. I Compile the drilldown example, and i made some changes and it worked.

        @ QSqlDatabase db = QSqlDatabase::addDatabase("QPSQL");
        qDebug()<<db.drivers();
        db.setDatabaseName("mydb");
        db.setUserName("postgres");
        db.setPassword("postgres");
        db.setHostName("localhost");
        db.setPort(5432);@
        I allready, tried this snippet on my project, and it worked.

        Looks like the problem was the db.port wasn't define. But im not sure. as long as it works, i don't care.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Some database system needs more information than others so it might very well be that.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          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