Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Unless you prefix it with a slash (on unix) or a drive path (Windows), QFile's constructor parameter is a <em>relative path</em> - relative to the current working directory. score.txt is created in the build/ directory because that's probably where you're executing the binary from.</p> <p>You can't store score.txt in the /usr/bin directory because, typically, you can't write there without root privileges. </p> <p>What you want to do is get a path to some directory where you can store your score.txt file. To do that, you can use the <code>QDesktopServices</code> class. That will give you directory information on a per-user basis. Here's an example:</p> <pre><code>#include &lt;QDesktopServices&gt; // this would go in main(), probably QCoreApplication::setApplicationName( "word jumble game" ); // now when you want to read/write the scores file: QString dataPath = QDesktopService::storageLocation( QDesktopService::DataLocation ); QFile scoreFile( dataPath + "score.txt" ); // on my system, this produces: "/home/adam/.local/share/data/word jumble game/score.txt" // it will produce something similar for Windows and Mac too </code></pre> <p>You should set your appication name via <code>QCoreApplication::setApplicationName</code> before getting path information to keep the user data directory nice and organised.</p> <p>As for getting your application in the games list, you'll need to create a menu entry that follows the freedesktop.org spec. <strike>I can't help you more with that, but <a href="http://standards.freedesktop.org/menu-spec/latest/" rel="nofollow">this</a> is a good starting point. Somebody else might have more info for you.</strike></p> <p>You need to create a .desktop entry file and install it using <code>xdg-desktop-menu install</code>. Here are two resources for you: <a href="http://standards.freedesktop.org/menu-spec/latest/" rel="nofollow">freedesktop.org menu spec</a> and <a href="http://www.cmake.org/pipermail/cmake/2010-September/039413.html" rel="nofollow">adding .desktop files using CMake</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload