Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Gui app on Mac doesn't see my SQLite database, when launched by double-click on .app itself
Forum Updated to NodeBB v4.3 + New Features

Gui app on Mac doesn't see my SQLite database, when launched by double-click on .app itself

Scheduled Pinned Locked Moved Solved Installation and Deployment
6 Posts 4 Posters 1.6k Views 2 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.
  • M Offline
    M Offline
    Maxxii
    wrote on last edited by
    #1

    Sorry for newbie questions, I'm not so familiar with deployment, but I don't know where to start.
    So, when Qt compiles and runs my app, everything works fine, but when I try to double click on app file/package from Debug (or Release) folder - app doesn't see database (won't write or show it's content). The difference is: Qt is launching not app itself, but executable from app package (sqltablemodel3.app/Contents/MacOS/sqltablemodel3).
    I tried to investigate, but found only some thread from 2010 with broken doc link. Also, I see official info for "The Mac Deployment Tool", but in Qt in Build menu I see some separate "Run without deployment" option. Does it mean, that deployment automatically runs by default?
    Am I missing some step?

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      http://doc.qt.io/qt-5/osx-deployment.html

      The deployment tool is a command line tool that you run your self.
      ( at least on windows)

      I assume it will be the same on macOS

      1 Reply Last reply
      3
      • M Offline
        M Offline
        Maxxii
        wrote on last edited by Maxxii
        #3

        I'm just not sure I need deployment at this point, because I don't want to distribute my app. I just wanted it to launch by clicking on .app file.
        I think I figured it out by searching again at this forum and reading through some more (not-Mac related) topics.
        So, I fixed this by adding QCoreApplication::applicationDirPath() to the path of my database, so now it looks like this:

        db.setDatabaseName(QCoreApplication::applicationDirPath()+"db.sqlite");
        
        cfdevC 1 Reply Last reply
        0
        • M Maxxii

          I'm just not sure I need deployment at this point, because I don't want to distribute my app. I just wanted it to launch by clicking on .app file.
          I think I figured it out by searching again at this forum and reading through some more (not-Mac related) topics.
          So, I fixed this by adding QCoreApplication::applicationDirPath() to the path of my database, so now it looks like this:

          db.setDatabaseName(QCoreApplication::applicationDirPath()+"db.sqlite");
          
          cfdevC Offline
          cfdevC Offline
          cfdev
          wrote on last edited by
          #4

          @Maxxii said in Gui app on Mac doesn't see my SQLite database, when launched by double-click on .app itself:

          db.sqlite

          be carefull because QCoreApplication::applicationDirPath() return the location inside the app bundle, if you place your database at the same level that yourapplication.app it will doesnt work.

          M 1 Reply Last reply
          2
          • cfdevC cfdev

            @Maxxii said in Gui app on Mac doesn't see my SQLite database, when launched by double-click on .app itself:

            db.sqlite

            be carefull because QCoreApplication::applicationDirPath() return the location inside the app bundle, if you place your database at the same level that yourapplication.app it will doesnt work.

            M Offline
            M Offline
            Maxxii
            wrote on last edited by
            #5

            @cfdev
            Ok, thank you for advice.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Hi,

              To add to @cfdev good point, you should use QStandardPaths to retrieve a proper folder to store your database.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              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