Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>For icons I would just use a resource file, as you did.</p> <p>If you want to store other files inside executable's directory (or children directories) you can prepend the string returned from <a href="http://qt-project.org/doc/qt-4.8/qcoreapplication.html#applicationDirPath" rel="nofollow"><code>QCoreApplication::applicationDirPath()</code></a>:</p> <pre><code>QString prefix = QCoreApplication::applicationDirPath(); QIcon startIcon(prefix + "/pictures/start.png"); startAction = new QAction(startIcon, tr("&amp;Start/Continue"), this); ... </code></pre> <p>However this does not comply with Linux / Unix filesystem, since the executable will likely be in <code>/usr/bin</code> and you can not really put resources in that directory. You might store resources in some other location (e.g. <code>/usr/share/yourapp</code>) and store that directory in some location in <code>/etc</code> during installation. Then your application gets the resources directory via <a href="http://qt-project.org/doc/qt-4.8/qsettings.html" rel="nofollow">QSettings</a>.</p> <p>See <a href="http://qt-project.org/doc/qt-4.8/qsettings.html#locations-where-application-settings-are-stored" rel="nofollow">this note</a> to decide what is the best location for storing that information (you can however read any file with QSettings).</p> <pre><code>QSettings settings(QSettings::SystemScope, QCoreApplication::organizationName(), QCoreApplication::applicationName()); // This points to /etc/xdg/MySoft.conf on Unix. QString prefix = settings.value("resourcesDirectory"); // Inside /etc/xdg/MySoft.conf you have a 'resourcesDirectory' // entry with value '/usr/share/MySoft/resources' ... </code></pre>
 

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