[odb-users] error adding QString to person example 1.5.0

Dan Coffey dcoffey at netharmonix.com
Mon Aug 1 10:54:24 EDT 2011


Hi Boris,

I'm building your examples using Qt Creator.
I've renamed the person class - Rdolls
All worked will until I add a QString to the Rdolls class.

Qt will compile correctly but when I post process I get this error:
rdolls.h:22:11: error: unable to map C++ type '::QString' used in data 
member 'middle_' to a database type
rdolls.h:22:11: info: use '#pragma db type' to specify the database type
line 22 is QString middle_;
(I also tried this using the employee class in the qt directory and get 
the same error, Qt will compile but I get this same post processing error)

#ifndef RDOLLS_H
#define  RDOLLS_H
*#include  <QtCore/QString>*

#include  <string>

#include  <odb/core.hxx>

#include  "rdolls_global.h"

#pragma  db  object

class  RDOLLSSHARED_EXPORT  Rdolls  {

public:

   Rdolls();

private:

   friend  class  odb::access;

#pragma  db  id  auto

   unsigned  long  id_;


   QString  middle_;
   std::string  first_;

   std::string  last_;

   unsigned  short  age_;

};

#endif  //  RDOLLS_H



Without the two lines:

  * #include<QtCore/QString>
  * QStringmiddle_;

The Rdolls class builds correctly in Qt.
And
I then post process with the command:
odb -d mysql --generate-query --generate-schema rdolls.h 
-I/usr/local/include/mysql -I/usr/local/include/qt4/ 
-I/usr/local/include/boost -I/usr/local/include -I/usr/local/include/odb

And the expected files are generated and I have loaded the sql into the 
mysql db.
-rw-r--r-- 1 Dan Coffey Administrators 15638 Aug  1 09:40 rdolls-odb.cxx
-rw-r--r-- 1 Dan Coffey Administrators  4616 Aug  1 09:40 rdolls-odb.hxx
-rw-r--r-- 1 Dan Coffey Administrators  1359 Aug  1 09:40 rdolls-odb.ixx
-rw-r--r-- 1 Dan Coffey Administrators   326 Aug  1 09:40 rdolls.sql

Thanks,

Dan








More information about the odb-users mailing list