[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: Use KTextEditor In Custom Widget Rather Than As Central Widget of MainWindow
From:       Dominik Haumann <dhaumann () kde ! org>
Date:       2014-11-17 18:05:30
Message-ID: 88523039.1zUpPmZfFo () eriador
[Download RAW message or body]

> > On Sunday 16 November 2014 04:20:28 Jason Alan Smith wrote:
> >> Hello everyone,
> >>
> >>     I am developing an application that helps users and developers manage
> >> a variety of database servers, and I would like to use a KTextEditor (or
> >> Kate) as my text editing widget as it has line numbering and syntax
> >> highlighting capabilities built in.
> >>
> >> ...
> >>
> >>     I am having difficulties figuring out how to accomplish this. I've
> >> looked at the source code for various applications, including Kile and
> >> Quanta, and have even started looking at KDevPlatform. I'm sure I could
> >> figure this out with enough time from one or more of these applications,
> >> but I was wondering if anyone could point me to a tutorial or a small,
> >> simple application, or a minimal code snippet or example that
> >> demonstrates how to achieve this. Thank you for your time.
> > Is this on KDE4 or KF5 ?
> Apologies for not specifying. This is KDE4.
> > In KDE4, you first have to do something like this:
> >
> > KTextEditor::Editor *editor = KTextEditor::EditorChooser::editor();
> > if (!editor) {
> >    // the KTextEditor implementaiton was not found
> > }
> >
> > KTextEditor::Document * document = editor->createDocument(parentObject);
> > KTextEditor::View * view = editor->createView(parentWidget);
> > view = document->createView(this);
> >
> > ...
> >
> > Hope that helps,
> > Dominik
> >
> Thank you, Dominik. I gave it another go, and I think I'm further along 
> than I was last night. I am, however, stumped now by the following error:
> 
>      invalid conversion from ‘KTextEditor::View*' to 
> ‘AssetQueryEditorWidget*'
> 
> I'm trying to do this:
> 
>      class AssetQueryEditorWidget : public KTextEditor::View {}
>
> and inside class AssetQuerySessionWidget do the following from your 
> suggestions:
> 
>      KTextEditor::Editor *editor = KTextEditor::EditorChooser::editor();
> 
>      newDocument = editor->createDocument(0);
>      assetQueryEditorWidget = newDocument->createView(this);

This does not work. KTextEditor::Document::createView() always creates a
KTextEditor::View. In other words, it will never create a AssetQueryEditorWidget.
You cannot 'upcast' a KTextEditor::View.

The KTextEditor interfaces are not designed that you derive from KTextEditor::View.
Please consider just wrapping it by using a member variable.

> I think I may need a cast but I'm honestly not sure if I'm even on the 
> right track with this.
> 
> If you or anyone is willing to have a further look, I've committed the 
> broken code to GitHub here:
>      https://github.com/QualityAddict/MorpheusDataPlatform
> 
> Thank you again for your time, Dominik. Take care.

Greetings,
Dominik

>> 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