Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-28087

Code navigation: Add ability to open resource files from URL literals

    XMLWordPrintable

Details

    • 9f9c40b29 (master)

    Description

      // main.cpp
      int main(int argc, char *argv[])
      {
          QGuiApplication app(argc, argv);
          QQmlApplicationEngine engine;
          const QUrl url(u"qrc:/main.qml"_qs); // "Follow Symbol Under Cursor" on the string literal should open qrc:/main.qml
          engine.load(url);
          return app.exec();
      }
      
      // main.qml
      Window {
          Image {
              source: "qrc:/myimage.png" // "Follow Symbol Under Cursor" on the string literal should open qrc:/myimage.png
          }
          Component.onCompleted: {
              console.log( Qt.resolvedUrl("data/config.ini") ) // "Follow Symbol Under Cursor" on the string literal should open "qrc:/data/config.ini"
          }
      }
      

      If it is not feasible for the code model itself to differentiate between URL literals from regular string literals (and evaluate relative URLs), perhaps this can be implemented as a separate function ("Open Resource Under Cursor"?) instead of "Follow Symbol Under Cursor". When activated, the function would check if the cursor is over a string literal, and if so, try to figure out the location of the specified file.

      Attachments

        Issue Links

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

          Activity

            People

              qtqmlteam Qt Qml Team User
              skoh-qt Sze Howe Koh
              Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes