Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. 3rd Party Software
  4. How to use "QDbf" under Windows?
QtWS25 Last Chance

How to use "QDbf" under Windows?

Scheduled Pinned Locked Moved 3rd Party Software
4 Posts 2 Posters 3.1k 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.
  • P Offline
    P Offline
    Pilstrinker
    wrote on last edited by
    #1

    Hey guys,

    I have to read out a .dbf-file (I know, it's very old, but the files are still used in this case and my App has to import them).
    Via google, I have found the Library "QDbf" ([url]http://code.google.com/p/qdbf/[/url]) and tested it under Mac OS X and everything works perfect.
    Then, I tried to compile it under Windows (7) with MinGW, because the App will be mainly used under Windows. But I get lots of Warnings and a strange Error:
    [CODE]definition of static data member 'QDbf::QDbfTableModel::staticMetaObjectExtraData' of dllimport'd class[/CODE]
    in "moc_dbftablemodel.cpp".

    My example-Code, I tried to compile is:

    [CODE]#include "qdbftable.h"
    #include "qdbfrecord.h"
    #include <QtGui>

    int main(int argv, char **args)
    {

    QApplication app(argv, args);

    QTextEdit textEdit;
    textEdit.show();

    QDbf::QDbfTable table;
    if (!table.open("datei.dbf")) {
    qDebug() << "file open error";

    }

    QString output;

    while (table.next()) {

    QDbf::QDbfRecord record = table.record();
    for (int i = 0; i < record.count(); ++i) {
        
      if(!(record.value(i).toString().trimmed()==""))
         {
      if(record.fieldName(i)=="NAME")
         {
            output.append(record.fieldName(i));
              output.append(QLatin1String(": "));
                output.append(record.value(i).toString().trimmed());
              output.append(QLatin1String("; \n"));
         }
      if(record.fieldName(i)=="PRENAME")
      {
         output.append(record.fieldName(i));
           output.append(QLatin1String(": "));
             output.append(record.value(i).toString().trimmed());
           output.append(QLatin1String("; \r \n"));
      }
         }
    
    }
    qDebug() << output;
    

    }

    table.close();
    textEdit.setText(output);

    return app.exec();

    }[/CODE]

    The Header/Source-Files are in the same directory with the main.cpp.

    And now my Questions:

    • How do I import a class correctly in my Qt environment? Have the Lib to be integrated, or is it enough to copy it in the Dir with my other sourcefiles?
    • Can I import it as a .dll? Because the Example in the QDbf-Package compiles correctly under Windows/MinGw and creates a .dll and .a-File. When I include it via "LIBS += ..." in my .pro-file, nothing happens. How do I include it correctly and use the functions of the dll in my Code?

    Hope you can help me getting this to run! ;)

    Greetings, Julian

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

      Hi,

      You don't need to copy anything.
      @
      INCLUDEPATH += C:/PATH_TO_QDBF_INCLUDE_FILES
      LIBS +=
      -LC:/PATH_TO_QDBF_DLL \ #<- This one without spaces would be best
      -lqdbf # have the correction name for debug/release builds
      @
      And you should be good.

      Hope it helps

      [edit, code added]

      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
      • P Offline
        P Offline
        Pilstrinker
        wrote on last edited by
        #3

        FUCK YEAH, it WORKS! :D
        Thank you very much!!!

        But I had to avoid relative paths, only the absolute "C:/..." worked for me.

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

          I also prefer to use full paths, in that case I know exactly where the linker will look for the libs.

          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