[Qt-creator] Capture Application Output via Plugin

Daniel Engelke dan at dew1.net
Sat May 8 01:12:06 CEST 2021


Thanks, Christian, that looks a lot cleaner.

 

Dan

 

From: Qt-creator <qt-creator-bounces at qt-project.org> On Behalf Of Christian
Kandeler
Sent: Thursday, May 6, 2021 4:45 PM
To: qt-creator at qt-project.org
Subject: Re: [Qt-creator] Capture Application Output via Plugin

 

On 5/6/21 4:23 PM, Daniel Engelke wrote:

I want to process the application output (find errors during runtime, stats,
etc.).

The "from" is an external plugin implementing ExtensionSystem::IPlugin.

Step 1: Subclass Utils::OutputLineParser and override the handleLine()
function. This gives you the application output, line by line. Pass it on to
your business logic and return Status::NotHandled.

Step 2: Subclass ProjectExplorer::OutputFormatterFactory. In the
constructor, do something like this:

    setFormatterCreator([](Target *t) -> QList<OutputLineParser *> {
        return {new MyOutputParser};
    });

Step 3: Instantiate this factory class somewhere "persistent", e.g. as a
member of your Plugin class.

 

That should be it.

All of this assumes that you do not have your own RunConfiguration subclass,
but you really want to capture any run control's output.

 

 

Christian

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/qt-creator/attachments/20210508/a18bc0a0/attachment.html>


More information about the Qt-creator mailing list