Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Qml QmlApplicationViewer

Qml QmlApplicationViewer

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 2 Posters 3.5k 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.
  • R Offline
    R Offline
    rishygupta
    wrote on last edited by
    #1

    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]

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      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.

      (Z(:^

      1 Reply Last reply
      0
      • R Offline
        R Offline
        rishygupta
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

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

          (Z(:^

          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