You are not logged in.

Dear visitor, welcome to KDE-Forum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

  • "David Boosalis" started this thread

Posts: 10

Location: Fresno California, USA

  • Send private message

1

Wednesday, September 15th 2004, 1:17am

Another KPart question

I must be the second bigest idiot in the world (modesty keeps me from claiming to be the biggest). I would like to use KIconEdit as a part. I've taken a few baby steps thanks to help from this board in getting KHTMLPart to render. So here is what I have for KIconEdit

BrowserDialog::BrowserDialog( QWidget* p, const char* n, bool m, WFlags fl ):
KParts::MainWindow(p,n,fl),m_part( 0L )

{
KActionCollection* act = actionCollection();
(void) KStdAction::open( this, SLOT( slotFileOpen() ), act, "file_open" );
(void) KStdAction::quit( this, SLOT( close() ), act, "file_quit" );
setXMLFile( "/opt/kde3/share/apps/kiconedit/kiconeditui.rc");
createGUI(0L);
// setCentralWidget( m_part->widget()); // core dumps
}

This leads to a menubar (with menus), a few ToolButtons and nothing else.
Perhaps I need to set the central widget as before, but if I uncomment this line above I get a core dump.

Does anybody know of a KDE3 app that uses KParts, I've looked at ten or so KDE applications and none of them use a KPart.

I am willing to document this, and post as I think KParts should be encouraged for a lot of reasons:
1) Cut down on code bloat.
2) Uniform look and Feel
3) Stability


Any advice, other then find a new hobby ?

-david
QT Developer

anda_skoa

Professional

Posts: 1,273

Location: Graz, Austria

Occupation: Software Developer

  • Send private message

2

Wednesday, September 15th 2004, 12:57pm

RE: Another KPart question

Quoted

Originally posted by David Boosalis
Perhaps I need to set the central widget as before, but if I uncomment this line above I get a core dump.

Could it be it core dumps because you have initialized m_part to 0 and dereferencing a nullpointer is not something you should do? :D

Maybe it would be better to actually create an instance of the part before trying to use it?
In this case you don't even have to set the XML file, the part does this itself.

Cheers,
_
Qt/KDE Developer
Debian User

  • "David Boosalis" started this thread

Posts: 10

Location: Fresno California, USA

  • Send private message

3

Wednesday, September 15th 2004, 7:32pm

RE: Another KPart question

Thank you for the feed back, so if I don't use the XML file what is the call I make for a KIconedit part instance. I have searched the for kiconedit.h and have found it only in the KDE source directory. The kiconeditui.rc file tells me nothing on how to create a Class( or does it).


Is there a special directory for .h files with respect to kparts.

Sorry for the ignorance here. I really want to try and use KPparts, and by posting here I hope that I am helping others understand how to use them

-david
QT Developer

anda_skoa

Professional

Posts: 1,273

Location: Graz, Austria

Occupation: Software Developer

  • Send private message

4

Wednesday, September 15th 2004, 8:54pm

RE: Another KPart question

Quoted

Originally posted by David Boosalis
Thank you for the feed back, so if I don't use the XML file what is the call I make for a KIconedit part instance. I have searched the for kiconedit.h and have found it only in the KDE source directory.

Well, very likely there is no such thing as a KIconEdit KPart.
I have only KDE3.2 here so I can't speak for the more recent KDE3.3, but on KIconEdit from 3.2 does not install any libs, which would be necessary if it was available as a KPart.

Remember that a KPart is some kind of plugin, so it is implemented inside a shared library (.so file)

Quoted


The kiconeditui.rc file tells me nothing on how to create a Class( or does it).

No, the ui.rc file describes the placement of actions in menus and toolbars (and those menus and toolbars)

Quoted


Is there a special directory for .h files with respect to kparts.

Not necessarily.
If a component which is available as a KPart has a lot of headers to install, it might have its own subdirectory in KDE's include directory.

There are two ways to use a part:
- directly create an instance of a known class, as you did in your KHTMLPart example
- load a potentially unknown part depending on requested properties/capabilities.

First usage is like with any other class:
- include header
- new Classname(parameters);
- link program to necessary libs

Loading is more complicated but keeps the application from depending on the parts library.
Usual steps here:
- include interface headers
- make a service lookup
- load factory depending on result
- have factory create a part instance
- cast to interface

Cheers,
_
Qt/KDE Developer
Debian User

  • "David Boosalis" started this thread

Posts: 10

Location: Fresno California, USA

  • Send private message

5

Wednesday, September 15th 2004, 10:27pm

RE: Another KPart question

anda_skoa

Thanks for your informative reply. It realy cleared up a lot of misconceptions I had about KParts. I just assumed that when I saw a resource file and in it was a XML <kpart> tag, that there was a part lurking in a library to to be used.

If I want to continue this effort of having a KPart for KIConEdit(and other applications), do you think it will be easy to do so. I guess there is a lot of documention on how to do this, they make it sound easy, but seeing that there are not a lot of kparts perhaps it isn't. Anyway, I'll give it a go.

-david
QT Developer

anda_skoa

Professional

Posts: 1,273

Location: Graz, Austria

Occupation: Software Developer

  • Send private message

6

Friday, September 17th 2004, 6:13pm

RE: Another KPart question

Quoted

Originally posted by David Boosalis
Thanks for your informative reply. It realy cleared up a lot of misconceptions I had about KParts. I just assumed that when I saw a resource file and in it was a XML <kpart> tag, that there was a part lurking in a library to to be used.

Maybe the author of KIconEdit planned to create a part of his code or will do so in a newer version.

Quoted


If I want to continue this effort of having a KPart for KIConEdit(and other applications), do you think it will be easy to do so. I guess there is a lot of documention on how to do this, they make it sound easy, but seeing that there are not a lot of kparts perhaps it isn't. Anyway, I'll give it a go.


Creating a part is not so difficult, so maybe there was no need yet for a such a part or the current maintainer lacks the time to implement the changes (quite some code change on the application to become a part wrapper).

Cheers,
_
Qt/KDE Developer
Debian User