[Qt-creator] Macro plugin 0.2

Eike Ziller eike.ziller at nokia.com
Fri Jan 29 16:39:22 CET 2010


Hej,

On Jan 29, 2010, at 3:32 PM, ext Nicolas Arnaud-Cormos wrote:

> On Friday 29 January 2010 15:14:45 Kuiper, Luuk wrote:
>> Nicolas,
>> 
>> How to use the search function within macros, as you mention in your
>> announcement?
> 
> Ctrl+F, the normal shortcut, then type your text. You can then use F3 to 
> search next.
> I'm just filtering the events and using my own not so good search.
> 
> Unfortunately, for the moment I'm unable to use the search from Qt Creator (or 
> if it's possible, I didn't find how yet). That's on my todo list (first item 
> currently) for this plugin.

Generally speaking you need to "attach" a Find::IFindSupport implementation to your widget that has focus when the user presses ctrl+f. And provide a place for the find tool bar to show up by adding a Core::FindToolBarPlaceHolder into your layout.

Look how it's done e.g. for the Compile Output pane:
The OutputPaneManager adds a FindToolBarPlaceHolder for all output panes to it's layout:

outputpane.cpp:
OutputPaneManager::OutputPaneManager(QWidget *parent)
{
...
    mainlayout->addWidget(new Core::FindToolBarPlaceHolder(this));
...
}

The CompileOutputWindow itself specifies the IFindSupport to use by coupling the widget with the IFindSupport instance:

compileoutputwindow.cpp:
CompileOutputWindow::CompileOutputWindow(BuildManager * /*bm*/)
{
...
    Aggregation::Aggregate *agg = new Aggregation::Aggregate;
    agg->add(m_textEdit);
    agg->add(new Find::BaseTextFind(m_textEdit));
}

(BaseTextFind is an implementation of IFindSupport for QTextEdit and QPlainTextEdit.)
(Aggregate is used to combine several QObjects into one, that can then be "cast" to each other with Aggregation::query<PointerType>(object), see the documentation in aggregate.cpp .)

Good luck!
-- 
Eike Ziller
Software Engineer
Nokia, Qt Development Frameworks

Nokia gate5 GmbH
Firmensitz: Invalidenstr. 117, 10115 Berlin, Germany
Registergericht: Amtsgericht Charlottenburg, Berlin: HRB 106443 B
Umsatzsteueridentifikationsnummer: DE 812 845 193
Geschäftsführer: Dr. Michael Halbherr, Karim Tähtivuori







More information about the Qt-creator-old mailing list