Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] Pass an Url in a .qrc file from QML to C++

[SOLVED] Pass an Url in a .qrc file from QML to C++

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.4k Views 1 Watching
  • 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.
  • K Offline
    K Offline
    Korchkidu
    wrote on last edited by
    #1

    Hi,

    I have been hitting the wall again and again and it seems I simply can't do it.

    I want to give a relative path to a file in a qrc file in QML, call a C++ function with this QUrl as a parameter and open the associated file in C++.

    in QML
    @ function run()
    {
    var file = "qrc:///myFile.js"
    myFunc(file)
    }@

    In CPP
    @myFunc(const QUrl &fileUrl)
    {
    <open file, read it, etc>
    }@

    It seems I can't do such a simple thing...;'(

    Any help would be welcome.
    Thanks!

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

      Use QString as the function parameter. QFile needs a string anyway, so it will even save you conversion time.

      (Z(:^

      1 Reply Last reply
      0
      • K Offline
        K Offline
        Korchkidu
        wrote on last edited by
        #3

        It works perfectly! Thanks!

        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