Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-118792

qmltyperegistrar: Make errors/warnings more prominent in Qt Creator

    XMLWordPrintable

Details

    • c12e55dbd (dev)

    Description

      Problem in the attached project

      The attached project fails to build because the QML_ELEMENT is defined in a *.cpp file rather than a *.h file. Consequently, qmltc is unable to find the QML_ELEMENT definition. (If qmltc is not enabled, then the project builds and runs just fine)

       

      The most prominent diagnostic messages are misleading

      However, the root cause of the problem is not obvious from Qt Creator's "Issues" pane. These are the first errors (reported by qmltc):

      Error: D:/Test/QmltcStudy/Main.qml:2:1: Warnings occurred while importing module "MyModule": [import]
      import MyModule
      ^^^^^^
      ---
      Error: Failed to import MyModule. Are your import paths set up properly? [import]
      ---
      
      Error: D:/Test/QmltcStudy/Main.qml:9:2: CppObj was not found. Did you add all import paths? [import]
      	CppObj {}
      	^^^^^^
      

      These messages could reasonably lead the user start looking at how to set import paths, even though the import paths are perfectly fine.

       

      The useful diagnostic message is not prominent

      The more useful warning is buried among the CMake output in the "Compile Output" pane (reported by qmltyperegistrar):

      Class CppObj is declared in cppobj.cpp, which appears not to be a header.
      The compilation of its registration to QML may fail.
      

      This message is more likely to prompt the user to move the QML_ELEMENT definition to a *.h file.

      Unfortunately, Qt Creator is unable to discern that this is an actionable warning, so the message doesn't appear in the "Issues" pane and isn't highlighted in the "Compile Output" pane.

       

      Suggestion
      Prefix qmltyperegistrar outputs with "Info:"/"Warning:"/"Error:" to provide a hint to Qt Creator (see QTCREATORBUG-28720 and https://codereview.qt-project.org/c/qt-creator/qt-creator/+/483236 )

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              ulherman Ulf Hermann
              skoh-qt Sze Howe Koh
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes