[SOLVED]"Update of Generated Files" message



  • HI

    I made a now QT-Quick Project with the wizard.

    Then I changed the qmlapplicationviewer.h and .cpp to make the connection between the qml and my C++-Classes.
    Now everytime I reload the project in the Creator, I got the message:

    The following files are either outdated or have been modified:

    qmlapplicationviewer.h, qmlapplicationviewer.cpp

    Do you want Qt Creator to update the files? Any changes will be lost.

    How can I get rid of this message forever? It is very dangerous, because I click accidently "YES", all my changes are lost.



  • Well, you should not modify those files in the first place as they are generated and subject to change (the same way you should not modify code generated out of .ui files).

    What is the "connection between the qml and my C++-Classes" that absolutely requires to modify those files? QmlApplicationViewer is-a QDeclarativeView so you can access all members like the rootContext and a like to add context properties anywhere you have access to your QmlApplicationViewer, for example in main():
    @
    Q_DECL_EXPORT int main(int argc, char *argv[])
    {
    QScopedPointer<QApplication> app(createApplication(argc, argv));
    QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create());

    viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
    viewer->setMainQmlFile&#40;QLatin1String("qml/qmltest/main.qml"&#41;);
    viewer->showExpanded();
    
    // place your connection code here, outside of the generated files 
    viewer->rootContext()->setContextProperty(..., ...);
    
    return app->exec&#40;&#41;;
    

    }
    @



  • I got from another source the following information:

    To get rid of the message, remove the checksum in the first line of qmlapplicationviewer.h and .cpp

    I did it, and it works fine for my purpose



  • Well, people also use pragmas and compiler switches to get rid of unpleasant compiler warnings - which doesn't make such a practice right too as you are fine for now, but you will probably run into serious troubles later on.


Log in to reply
 

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