ich habe ein kleines Problem. Hab zwar schon die Suchfunktion, Google, diverse Bücher und den QT-Assistant befragt, wurde aber nicht schlau.
Ich habe nen einfachen Texteditor gecoded, nun möchte ich eine Suchfunktion implementieren um einzelne Strings hervorzuheben. Ihr wisst schon, wie bei Notepad unter Windows, oder Kate unter Linux.
Code: Alles auswählen
search = new QAction("&Search", this);
search->setShortcut(QString("Ctrl+F"));
search->setStatusTip("Search");
connect(search, SIGNAL(triggered()), this, SLOT(slotSeek()));Code: Alles auswählen
void EditorSDIlg :: slotSeek()
{
QString s = QInputDialog::getText(this, tr("Seek a Word"),tr("Search for:"));
}Bin auf folgendes gestossen:
Code: Alles auswählen
bool QTextEdit::find ( const QString & exp, QTextDocument::FindFlags options = 0 )
Finds the next occurrence of the string, exp, using the given options. Returns true if exp was found and changes the cursor to select the match; otherwise returns false.Grüssle
Michel