Registered Member
|
So I derived my AppMainWindow from KParts::MainWindow and put setXMLFile( xmlfile ) in the constructor of my AppMainWindow. On the same level ( thus were the app runs ) Just for testing purposes I have a ui.rc file with the content:
but nothing happens.When debugging I can see that the code line is hit. What am I doing wrong? |
Administrator
|
Do you create the actions and add them to the action collection?
KDE Sysadmin
[img]content/bcooksley_sig.png[/img] |
Registered Member
|
I already had actions in my original QMainWindow but they were QActions. Do I need to transform them into KStandardActions?
|
Administrator
|
It depends on what they do.
The direct conversion is to KAction, which is what the second code snippet does. KAction adds a few things including KDE Shortcut infrastructure support to QAction. KStandardAction is what allows KDE applications to share actions which feel and look the exact same between each other. KStandardAction methods all return a KAction.
KDE Sysadmin
[img]content/bcooksley_sig.png[/img] |
Registered Member
|
I had actions like open, close, import, export and many others defined already in my app. Can I use these actions or do I need to use KActions and KMenu instead of QAction and QMenu.
|
Registered Member
|
Still testing and trying to get familiar with kpart and the ui xml technique but no luck. My application mainwindow is derived from KParts::MainWindow and in this class I create a KAction ("testprint", this ) and inside the constructior of this class I do a setXMLFile with a file in the same directory.
Anyone got an idea on what I forgot? |
Registered Member
|
I tried the full path to the ui.rc file and put a createGUI(0L) after the setXMLFile(). This results in another Help menu item in my menu bar besides the one I already got of my app. The new Help menu displays the KDE help. So can I conclude that my mainwindow is kpart aware? and why is the ui.rc file not read ( checked the name and path a 1000 times).
|
Administrator
|
In order to be found, ui.rc files need to be named <app name>ui.rc and installed to $(kde4-config --install data)/<appname>
If you do not want to install it to a system wide path, you will need to make some changes to your environment. Add the following to your ~/.bashrc:
You can then install your application to $HOME/kde4-local-prefix after logging out and back in again. The advantage of XMLGUI is that you do not need to create the menus manually as it will do it for you. You only need to convert your QAction's to KAction's, and add them to the action collection for it to work.
KDE Sysadmin
[img]content/bcooksley_sig.png[/img] |
Registered Member
|
Super..this works, a huge THANK YOU bcooksley .
I can see a test KAction in the file menubar item. Now I need to transform all my current QActions into KAction and put it in the XML file and my QMenu into KMenu. What's with the Help menubar item, can I get rid of it? as much as I like KDE, I've already got one and I don't need another Help in my app. Another question: currently my app also runs on Windows, I assume it will keep running after the XML transition with the necessary libraries and files that I need to include in my app...right? Now up to the real reason why I made my app kpart aware: the integration of kword/part. In a QMenu item "Reporting" I have a QAction "Add Report", this action brings the app in a reporting mode (just shows a few default tabs on the screen) and adds a new one with a QTextEdit object in this last tab. In the new situation I want it to put the kword/part in this tab. Any one any ideas? |
Administrator
|
You do not need QMenu's when working with XMLGUI, since it creates them for you, so you can delete them.
simply call setHelpMenuEnabled( false ); to disable the KDE help menu in your KXMLGUIWindow subclass. This needs to be done before any createGUI() or setupGUI() calls.
KDE Sysadmin
[img]content/bcooksley_sig.png[/img] |
Registered Member
|
But ofcourse, I forgot that bcooksley. I don't need any addMenu's anymore since the XMLGUI is taking care of that for me.But can you please give some comments on the other questions in my previous posting?
|
Registered Member
|
bcooksley gave me a suggestion about the ui.rc file that should be found if I export KDEDIR and KDEDIRS, but unfortunately it didn't work. I exported these environment variables in my .bashrc and then sourced this file and checked wether the variables have the right value in my shell and the started the app but it still says that it can't find the file myappui.rc even though it's on the same level as the application. The application is installed in /development/myapp and this directory is thus also added to KDEDIRS while the DKEDIR has a value $( kde4-config --prefix ) and that is /usr.
|
Administrator
|
What build system are you using? CMake can make handling where to install KDE related files much easier.
KDE Sysadmin
[img]content/bcooksley_sig.png[/img] |
Registered Member
|
actually my application makes use of project files (.pro) thus qmake. This makes Makefiles which are handled by GNUMake.
I hope this helps. |
Administrator
|
You should install the *ui.rc file to $prefix/share/apps/<your app name>/
Not sure how this is handled in QMake. Some distributions alter it to need for it to be installed in $prefix/share/kde4/apps/<your app name> instead however.
KDE Sysadmin
[img]content/bcooksley_sig.png[/img] |
Registered users: bancha, Bing [Bot], Evergrowing, Google [Bot], lockheed, mesutakcan