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. Application path did not work!
Forum Updated to NodeBB v4.3 + New Features

Application path did not work!

Scheduled Pinned Locked Moved General and Desktop
20 Posts 6 Posters 11.1k 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.
  • A Offline
    A Offline
    absfrm
    wrote on last edited by
    #1

    Hi to all
    i'm usin this code
    @
    QString path = QCoreApplication::applicationDirPath() + "/data/27115";
    @
    for get my application dir path to use it.
    in my System (Windows Seven 64Bits)are working
    but in other computer its not work!!
    why?

    If You Want You Can!

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

      How exactly is it failing? Segfault, empty string?

      (Z(:^

      1 Reply Last reply
      0
      • A Offline
        A Offline
        absfrm
        wrote on last edited by
        #3

        stupid problem!!
        it is return me true path (directory of execution file!). but not working!

        this is address of my db file.
        are there any way for get db address near exe file?
        my db address: data/257115.db that data folder is near exe file.

        If You Want You Can!

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andre
          wrote on last edited by
          #4

          The [[doc:QDir]] class has many methods to do manipulation of file paths.

          1 Reply Last reply
          0
          • G Offline
            G Offline
            goetz
            wrote on last edited by
            #5

            What is the value of path and what do you expect?
            Any qDebug() output?

            http://www.catb.org/~esr/faqs/smart-questions.html

            1 Reply Last reply
            0
            • A Offline
              A Offline
              absfrm
              wrote on last edited by
              #6

              the output is right but not working!
              you know.
              i'm using sqlite that db file is near my exe file in folder "data"

              in my OS (Win 7 64bits) working write,but my application in other os(other windows in other computer)
              cant access to db file!

              If You Want You Can!

              1 Reply Last reply
              0
              • A Offline
                A Offline
                andre
                wrote on last edited by
                #7

                [quote author="abbas farahmand" date="1327920166"]the output is right but not working!
                you know. [/quote]
                No, we don't know. What are you seeing exactly? What did you expect? And what is not working?
                [quote]
                i'm using sqlite that db file is near my exe file in folder "data"

                in my OS (Win 7 64bits) working write,but my application in other os(other windows in other computer)
                cant access to db file![/quote]

                But you are not showing us the relevant code for that, so how can we help you?

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

                  Maybe permissions are wrong on that other system? Also, you should probably add ".db" to the path.

                  (Z(:^

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    absfrm
                    wrote on last edited by
                    #9

                    :D
                    ok.
                    @
                    QSqlDatabase mydb = QSqlDatabase::addDatabase("QSQLITE");
                    mydb.setDatabaseName(QCoreApplication::applicationDirPath() + "/data/27115");
                    mydb.open();
                    if (mydb.open())
                    {
                    goview();
                    }
                    mydb.close();
                    }

                    @
                    27115 is my db file and don't has extension
                    i'm using this code and working right in my laptop now.but in other pc.... cant find db file!

                    If You Want You Can!

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

                      Although that is not related, you should not be invoking "mydb.open()" twice. You can delete one in line 3.

                      (Z(:^

                      1 Reply Last reply
                      0
                      • A Offline
                        A Offline
                        absfrm
                        wrote on last edited by
                        #11

                        [quote author="sierdzio" date="1327921175"]Although that is not related, you should not be invoking "mydb.open()" twice. You can delete one in line 3.[/quote]

                        No.this problem was not for this!
                        thanks

                        If You Want You Can!

                        1 Reply Last reply
                        0
                        • A Offline
                          A Offline
                          andre
                          wrote on last edited by
                          #12

                          What output do you get if you change your code to:
                          @
                          QSqlDatabase mydb = QSqlDatabase::addDatabase("QSQLITE");
                          QString databasePath = QCoreApplication::applicationDirPath() + "/data/27115";
                          qDebug() << "database location:" << databasePath;
                          mydb.setDatabaseName(databasePath);
                          mydb.open();
                          if (mydb.open())
                          {
                          goview();
                          }
                          mydb.close();
                          }
                          @

                          Please also tell us what output you expected there.

                          1 Reply Last reply
                          0
                          • A Offline
                            A Offline
                            absfrm
                            wrote on last edited by
                            #13

                            [quote author="Andre" date="1327922300"]What output do you get if you change your code to:
                            @
                            QSqlDatabase mydb = QSqlDatabase::addDatabase("QSQLITE");
                            QString databasePath = QCoreApplication::applicationDirPath() + "/data/27115";
                            qDebug() << "database location:" << databasePath;
                            mydb.setDatabaseName(databasePath);
                            mydb.open();
                            if (mydb.open())
                            {
                            goview();
                            }
                            mydb.close();
                            }
                            @

                            Please also tell us what output you expected there.[/quote]
                            the output is : @
                            database location:C:/Users/MR.Farahmand/Desktop/parsipedia-001-beta-build-desktop/debug/data/27115
                            @
                            the database address is true but....!!

                            If You Want You Can!

                            1 Reply Last reply
                            0
                            • A Offline
                              A Offline
                              andre
                              wrote on last edited by
                              #14

                              but what exactly?
                              You are sure that the database file really exists at that precise location?

                              1 Reply Last reply
                              0
                              • A Offline
                                A Offline
                                absfrm
                                wrote on last edited by
                                #15

                                but cant find db file
                                i'm copy db file to C:/ location and its working!
                                but in
                                @
                                mydb.setDatabaseName(QCoreApplication::applicationDirPath() + "/data/27115");
                                @
                                cant connect to db.(maybe cant find db file!)

                                If You Want You Can!

                                1 Reply Last reply
                                0
                                • G Offline
                                  G Offline
                                  goetz
                                  wrote on last edited by
                                  #16

                                  Can you please write complete sentences? And can you please stop filling in nonsense like "you know" - no, we don't. None of us has a crystal ball here and none of us knows what you're doing and what you're expecting.

                                  There is nothing like "database address is true" - that's a nonsens statement. We're talking about a path here. That can be valid or not. It can exist or not. But it can neither be true nor false. A bit more precision, please.

                                  Do you work with an existing database or do you create it at runtime?

                                  For the former:
                                  Does that path exist?
                                  Is it really a file and not a directory?
                                  Can your read it?
                                  Is it an sqlite database file?

                                  For the latter:
                                  Does your data subdirectory exist?
                                  If not: create it! Sqlite will not do this for you!

                                  http://www.catb.org/~esr/faqs/smart-questions.html

                                  1 Reply Last reply
                                  0
                                  • A Offline
                                    A Offline
                                    absfrm
                                    wrote on last edited by
                                    #17

                                    thanks
                                    I fixed it with other ways.

                                    If You Want You Can!

                                    1 Reply Last reply
                                    0
                                    • S Offline
                                      S Offline
                                      Seba84
                                      wrote on last edited by
                                      #18

                                      I don't believe what I see. This post is useless and it was a waste of time for all who participated...

                                      Seba84

                                      1 Reply Last reply
                                      0
                                      • A Offline
                                        A Offline
                                        absfrm
                                        wrote on last edited by
                                        #19

                                        Hi to all
                                        I'm so sorry for times that you used for this post
                                        that's problem was not for db file path
                                        web must copy sqldrivers folder to output folder (debug folder neer exe file).
                                        [quote author="Seba84" date="1328030127"]I don't believe what I see. This post is useless and it was
                                        a waste of time for all who participated...

                                        Seba84[/quote]
                                        any post can't be useless!!
                                        maybe some people have this problem exactly !

                                        thanks all

                                        If You Want You Can!

                                        1 Reply Last reply
                                        0
                                        • L Offline
                                          L Offline
                                          lgeyer
                                          wrote on last edited by
                                          #20

                                          [quote author="abbas farahmand" date="1328272043"]
                                          maybe some people have this problem exactly![/quote]

                                          Well, you never posted a solution.

                                          You described your problem, we plead for additional information and then
                                          [quote author="abbas farahmand" date="1328272043"]
                                          I fixed it with other ways.
                                          [/quote]

                                          So if you want this thread to have any valuable information for others you better hand in what actually solved your problem - what you now did.

                                          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