Using the Foxhound search bar in other programs

Submitted by Matthew Smith on Sun, 2008-02-17 00:53

QTM's "Foxhound" search bar is designed to be used in any Qt application which makes use of the Qt framework's QTextEdit class (at present; it may also be extended to other Qt classes which use Qt's document framework). Although adapted from the source code of Qt Assistant, Qt Assistant's search bar was integrated into the browser widget's code. This widget works using a QTextEdit pointer, which can be changed so that, if you have multiple editor or viewer widgets within one main window, you can use the same search bar and even search for the same text in more than one text widget.

The class presently consists of seven files. The stable version can be found here and it consists of these files: QijSearchWidget.h QijSearchWidget.qrc QijSearchWidget.ui images / close.png next.png previous.png

At the moment, it is not integrated as a Qt Designer plugin and is not supplied with a project file, so integrating it into your source code is up to you. As Qt Assistant is under the GPL and it reuses code from that application, it can only be used in GPL applications.

Class documentation


QijSearchWidget( QTextEdit *textEdit, QWidget *parent = 0 )

It must be supplied, in the first instance, with an editor widget pointer (this may change in future versions).

Public functions:

QTextEdit * textEdit()

Returns a pointer to its current editor/viewer widget.

bool expertEnabled()

Returns true if expert mode (i.e. regex searching) is enabled; false if it isn't.

Public slots:

void setTextEdit( QTextEdit *textEdit )

Sets the bar to work on the editor/viewer specified in textEdit.

void find()

Shows the search bar, and sets the keyboard focus to the search text entry space.

void findAgain()

Shows the search bar if it is invisible, and repeats the last search if there was one.

void setExpertEnabled( bool value )

Enables or disables regex searching (and hides the checkbox which governs it).

void clearSearchText()

Clears whatever the user has entered into the search text space.


void searchMessage( const QString &text )

Sends a message, intended to be displayed to the user (in the status bar, for example).