[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-devel
Subject: KXMLGui: Tutorial outdated and/or bug in KF5.4?
From: Christian Kalkhoff <ego () softmetz ! de>
Date: 2016-01-11 10:38:13
Message-ID: 7164576.mVtex5pC2F () hawking ! fritz ! box
[Download RAW message or body]
Hi,
I currently get myself started as KDE/QT developer. I created my application
and used the KF5-Tutorials in Techbase [1] and kate [2] as an example.
As I found out it is suggested to use KXmlGuiWindow [3] as base class for the
main window. Trying so i stumbled across a glitch that might be an outdated
tutorial and/or a bug in KF5.4, you decide. :)
As suggested by the tutorial [4] I created my kresistorui.rc (where kresistor
is the name of my project) and added
> install(FILES kresistorui.rc DESTINATION ${KXMLGUI_INSTALL_DIR}/kresistor)
to CMakeLists.txt. After building the project (using qtcreator) i tried to run
it and got
> cannot find .rc file kresistorui.rc for component kresistor
First i blamed myself and looked around for typos and other stuff. Afterwards
I straced the binary and found out, that it would try to open the file from
some system/userdir locations but not the build output dir.
I then searched the net and found what seemed to be a solution at the Marble
project [5]. Unfortunally adding KDEDIRS to the runtime environment did
nothing to solve my problem. I asked in IRC but nobody was sure what could be
the problem, KDEDIRS should haved helped, they said.
So I checked the documentation of KXmlGuiWindow again, but still no hint.
Finally i cloned the repository of kxmlgui [6], grep'ed around and found the
code of KXmlGui::setXmlFile. The source comment states, that from KF5.4
onwards the prefered way to add the ui.rc files is by using a QT5 resource and
store it under prefix ":/kxmlgui5". There is also some compatibility code that
checks for the files in the previous locations:
> // then compat locations
>
> const QStringList compatFiles =
>
> QStandardPaths::locateAll(QStandardPaths::GenericDataLoca
> tion, filter) + // kdelibs4, KF 5.0
> QStandardPaths::locateAll(QStandardPaths::GenericDataLoc
> ation, _file); // kdelibs4, KF 5.0, caller passes
> component name
So from all i have learned, the KDEDIRS environment variables seems to be
ignored for "QStandardPaths::GenericDataLocation".
Adding the qt5 resources worked by the way, that leaves me with two questions:
Is the tutorial outdated and I should adapt it to the present?
Is there a bug regarding KDEDIRS?
Best,
Christian
P.S. Final addition. Since i create a static library from my code (for running
tests) I had to call the macro Q_INIT_RESOURCE(kresistor) where kresistor is
the name of my qrc file. AFAIK that is only necessary for library code, not
for the binaries. Is that true?
[1] https://techbase.kde.org/Development/Tutorials/First_program/KF5
[2] https://quickgit.kde.org/?p=kate.git
[3] http://api.kde.org/frameworks-api/frameworks5-apidocs/kxmlgui/html/
classKXmlGuiWindow.html
[4] https://techbase.kde.org/Development/Tutorials/Using_KActions/KF5
[5] https://techbase.kde.org/Projects/Marble/QtCreator#Running_Marble
[6] https://quickgit.kde.org/?p=kxmlgui.git
--
Christian Kalkhoff - Softwarebefreier - software liberator
Fellow of FSFE - Support FSFE!
https://softmetz.de
https://blogs.fsfe.org/softmetz
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic