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] problem with TextFinder tutorial

[Solved] problem with TextFinder tutorial

Scheduled Pinned Locked Moved General and Desktop
7 Posts 2 Posters 5.3k 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.
  • mzimmersM Offline
    mzimmersM Offline
    mzimmers
    wrote on last edited by
    #1

    Hi, all -

    I'm brand new to all of this. I'm trying to do the TextFinder tutorial described here:

    "tutorial":http://doc.qt.nokia.com/qtcreator-2.0-snapshot/creator-writing-program.html

    I'm running on a Mac, by the way. The only change I saw necessary was to change this:

    @QFile inputFile(":/input.txt");
    @

    to this:

    @QFile inputFile("input.txt");
    @

    ...in the file textfinder.cpp.
    So, the program builds OK, but it doesn't open the input file. Nor does it give any error that I can see. Can anyone suggest what I might look at to get this working?

    I probably should point out that there were a couple of minor differences between my source files and the ones in the tutorial; probably a version issue.

    Thanks for any help.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      stukdev
      wrote on last edited by
      #2

      Are you sure you have the file in the correct position?
      Maybe you have build separate from the code (-shared- shadow build).

      1 Reply Last reply
      0
      • mzimmersM Offline
        mzimmersM Offline
        mzimmers
        wrote on last edited by
        #3

        No, I'm not sure. Wouldn't the application signal some kind of error, though, if the file couldn't be found?

        The file is in the same directory as the source code and everything else.

        Can you tell me a little more about shared build?

        Thanks for the reply.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          stukdev
          wrote on last edited by
          #4

          Sorry i mean shadow build.
          My little problem when qtcreator have introduct the shadow build is the correct position of file.
          In my case when i build with shadow build, i have a source folder called 'source' and qtcreator create a source-build-desktop with folder debug and release i have to put the file that i use in that folder.

          If you able the shadow build you can see the check in the project setting.

          Alternative you can simply use a qt "resource":http://doc.qt.nokia.com/4.7/resources.html for a static file.

          1 Reply Last reply
          0
          • mzimmersM Offline
            mzimmersM Offline
            mzimmers
            wrote on last edited by
            #5

            I am in fact using a resource file; it was generated when I created the project. I just noticed, though, that there was an error in it. Just to be safe, I deleted the project files and started fresh.

            Now, though, I notice that when I create the project per the tutorial, it skips a step that is mentioned in the tutorial, namely the Select Required Qt Versions dialog.

            Any idea why I might be skipping this, and whether it's important?

            1 Reply Last reply
            0
            • S Offline
              S Offline
              stukdev
              wrote on last edited by
              #6

              If you use a resource file, you have add a file in the resource then you have to use this code
              @QFile inputFile(":/input.txt");@ where :/input is the file that you have add to the resource.
              Past the code of the resource file.

              If you compile you have just select a version, but in the project setting there is the version of qt that you use for building the project.

              1 Reply Last reply
              0
              • mzimmersM Offline
                mzimmersM Offline
                mzimmers
                wrote on last edited by
                #7

                Ahh...it appears I out-smarted myself on this one. I assumed that the ":/" was part of a DOS file pathname. But, if I infer correctly from your post, it's actually used by Qt itself.

                I left it in this time, and the demo now appears to work. Thank you VERY much for your help. Now, I have to go do some more tutorials until I begin to actually understand this stuff...

                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