Qml QmlApplicationViewer



  • IN ABC.h
    @
    public:
    void fun(QmlApplicationViewer *viewer);
    @
    IN ABC.cpp
    @
    void fun(QmlApplicationViewer *viewer)
    {
    QmlApplicationViewer *viewer;

    viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
    viewer.rootContext()->setContextProperty("lstModel", QVariant::fromValue(modelList));
    viewer.rootContext()->setContextProperty("lstYear", QVariant::fromValue(yearList));
    viewer.setMainQmlFile(QLatin1String("qml/main.qml"));
    viewer.setResizeMode(QDeclarativeView::SizeRootObjectToView);
    viewer.setMinimumSize(1024, 650);
    viewer.rootContext()->setContextProperty("myModel",
    viewer.setWindowIcon(icon);

    QObject *rootObject = viewer->rootObject();
    Combo *com = new Combo(rootObject);
    nemoDB *nemo = new nemoDB(rootObject);
    return ;
    

    }
    @
    IN main.cpp
    @
    Q_DECL_EXPORT int main(int argc, char *argv[])
    {
    QApplication app(argc, argv);
    QmlApplicationViewer viewer;
    Qml obj;
    obj->fun(&viewer);
    viewer.show();

    return app.exec();
    

    }
    @

    but its giving me error that main.cpp:70: undefined reference to `Qml::fun(QmlApplicationViewer*)'

    can we use QmlApplicationViewer like this i mean not in main.cpp in another class
    and if we can whats is problem with this code..thanks

    [Edit: Please be sure to add @ tags around your code -- mlong]


  • Moderators

    You are setting the definition in ABC.cpp wrongly Should be:
    @
    void Qml::fun(QmlApplicationViewer *viewer)
    // etc...
    @

    It should be possible, but is a very strange way of doing it. Why not modify the QmlApplicationViewer itself? You can do it in the constructor, or some other method... or write your own, simpler viewer (that's what I usually do, because the default is mostly for Symbian, and I don't need that code).

    Also, please wrap your code in '@' tags, and make sure it's easily readable. Currently, it's hard to understand your point.



  • ohh thanks what a silly mistake...and by the way next time i will surely describe my point nicely


  • Moderators

    No problem, I'm just pointing out. It might help you get answers in the future.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.