Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. Path Query in QT
Qt 6.11 is out! See what's new in the release blog

Path Query in QT

Scheduled Pinned Locked Moved Unsolved Qt for Python
2 Posts 2 Posters 474 Views
  • 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.
  • A Offline
    A Offline
    AArju
    wrote on last edited by
    #1

    With QT I'm Using Python Embedding . In QT my project folder I kept one file there. So without using absolute path and Passing Full path I just want Read the python file by Python file name( as Relative Path) so while creating EXE can run in any system.

    Please help me, its very urgent

    pythonFile=PyImport_ImportModule("DistanceEstimation");

    ["Distance Estimation is python file"]
    This requirement is for creating EXE purpose]

    JonBJ 1 Reply Last reply
    0
    • A AArju

      With QT I'm Using Python Embedding . In QT my project folder I kept one file there. So without using absolute path and Passing Full path I just want Read the python file by Python file name( as Relative Path) so while creating EXE can run in any system.

      Please help me, its very urgent

      pythonFile=PyImport_ImportModule("DistanceEstimation");

      ["Distance Estimation is python file"]
      This requirement is for creating EXE purpose]

      JonBJ Online
      JonBJ Online
      JonB
      wrote on last edited by
      #2

      @AArju said in Path Query in QT:

      Please help me, its very urgent

      Hello and welcome.

      Everybody's question is "very urgent" to them!

      You cannot access "the project folder" from runtime code as you do not know where it is, and indeed it will not even be present on a non-development machine, unless you deploy your application and include the file somewhere.

      You have 4 basic choices:

      • Deploy your project (e.g. windeployqt) to include the file somewhere, and use that.
      • Place the file in the same directory as your executable (or somewhere known relative to it). You can access that via e.g. qApp-> applicationDirPath().
      • Place it in one of the paths accessible via one of the known directory paths in QStandardPaths.
      • Use Qt's resource system to embed the file into the executable and QFile to access it there.
      1 Reply Last reply
      2

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved