0
基本上我做了一個簡單的搜索功能,但它只有在用戶將光標移動到文本編輯開始時才起作用。我想知道是否有任何事情可以讓光標自動出現在那裏。任何投入將不勝感激。Qt C++如何在textedit的開始處獲取光標?
void Dialog::on_pushButton_clicked()
{
QString month;
QString day;
QString year;
month=ui->comboBox->currentText();
day=ui->comboBox_2->currentText();
year=ui->comboBox_3->currentText();
QTextCursor textCursor = ui->textEdit->textCursor();
textCursor.movePosition(QTextCursor::Start, QTextCursor::MoveAnchor,1);
QString date= month + "/" + day + "/" + year;
qDebug() << date;
ui->textEdit->find(date, QTextDocument::FindWholeWords);
}
這是否採取哪些參數? – user3183586
http://qt-project.org/doc/qt-4.8/qtextedit.html#setTextCursor – Throwback1986
對不起,我仍然在C + +新的東西我會爲const QTextCursor&光標 – user3183586