Problem caliing model with relationship from main.cpp

Forum for posting problems using QxOrm library

Problem caliing model with relationship from main.cpp

Postby algogr » Fri Jul 08, 2016 7:51 pm

Hello everyone,

I have problem finding the way to call model with relationships from main.cpp.
I have created the model/view library through QxEE but when i try to instantiate a class i get complier errors

Here is my main.cpp
Code: Select all
#include "precompiled.h"
#include <QGuiApplication>
#include <QApplication>
#include <QQmlApplicationEngine>
#include <QxMemLeak.h>
#include <QQmlContext>

#include "export.h"

#include "tasks.gen.h"


#include "hourglassqx_precompiled_header.model_view.gen.h"
#include "hourglassqx_export.model_view.gen.h"

//#include "hourglassqx_all_include.model_view.gen.h"

#include "tasks.model_view.gen.h"
int main(int argc, char *argv[])
{

    QApplication app(argc, argv);
    qx::QxSqlDatabase::getSingleton()->setDriverName("QMYSQL");
    qx::QxSqlDatabase::getSingleton()->setDatabaseName("hourglass_test");
    qx::QxSqlDatabase::getSingleton()->setHostName("localhost");
    qx::QxSqlDatabase::getSingleton()->setPort(3306);
    qx::QxSqlDatabase::getSingleton()->setUserName("root");
    qx::QxSqlDatabase::getSingleton()->setPassword("");
   
    qx::IxModel* tModel= new qx::QxModel<model_view::tasks_model>;
    tModel->qxFetchAll();
    qAssert(tModel->rowCount()!=0);
    QQmlApplicationEngine engine;
    engine.rootContext()->setContextProperty("taskModel",tModel);
    engine.load(QUrl(QStringLiteral("qrc:/main.qml")));

    return app.exec();
}



Is there anything wrong with the includes?
Thanks in advance
algogr
 
Posts: 3
Joined: Fri Jul 08, 2016 7:39 pm

Re: Problem caliing model with relationship from main.cpp

Postby qxorm » Fri Jul 08, 2016 8:37 pm

Hello,

In your main.cpp, you wrote :
Code: Select all
    qx::IxModel* tModel= new qx::QxModel<model_view::tasks_model>;
    tModel->qxFetchAll();


But your model_view::tasks_model class is already a qx::QxModel<T> : it inherits from qx::QxModel<T>.
So just write :
Code: Select all
    qx::IxModel* tModel = new model_view::tasks_model();
    tModel->qxFetchAll();
qxorm
Site Admin
 
Posts: 481
Joined: Mon Apr 12, 2010 7:45 am

Re: Problem caliing model with relationship from main.cpp

Postby algogr » Sat Jul 09, 2016 9:33 am

Thank you very much. I didn't pay attention to the generated classes. Now it compiles without problem.Thanks again
algogr
 
Posts: 3
Joined: Fri Jul 08, 2016 7:39 pm

Re: Problem caliing model with relationship from main.cpp

Postby qxorm » Mon Jul 11, 2016 7:39 am

Now it compiles without problem.Thanks again

Great !
qxorm
Site Admin
 
Posts: 481
Joined: Mon Apr 12, 2010 7:45 am


Return to QxOrm - Help

Who is online

Users browsing this forum: No registered users and 10 guests