Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Debug specific code



  • We need to add few code , for ex : skip few UI during debug or add new UI for debug . would like to include this only for debug.
    For now , we manage with isDebug flag in the main qml file. We are setting this vaue from the QML launcher cpp code.(Pardon me if the terminologies arent apt as i am quite new). But i need to set the flag before the instnace is created.Is there a way to achieve this.

    QT : 4.8 , cant update to latest due to hardware and config limitations

    QDeclarativeView viewer;
    viewer.setStyleSheet("background:grey");
    viewer.setSource(QUrl("qrc:/K/IBK/main.qml"));
    QGraphicsObject *rootObject = viewer.rootObject();
    rootObject->setProperty("isDebug",true);

  • Moderators

    You can use a Loader to load different (or none) QML files depending on whether your isDebug property is true or false.



  • @sierdzio Quite right. Although i would prefer to not change code flow much. If i could just set this flag before instance creation


  • Moderators

    @Ravisha said in Debug specific code:

    @sierdzio Quite right. Although i would prefer to not change code flow much. If i could just set this flag before instance creation

    You could do it with File Selectors, but they are not available in Qt 4. I don't see any other possibility.


Log in to reply