怎么对QTextEdit的文本实现双向查找操作
1个回答
展开全部
void MainWindow::slotFind(){
QString findtxt = editFind->text();
if(findtxt.isEmpty()){
QMessageBox::warning(this,tr("warning"),tr("No input"));
}else{
text->moveCursor(QTextCursor::Start);
if(!text->find(findtxt)){
QMessageBox::StandardButton btn;
btn = QMessageBox::information(this,tr("Find"),"cannot find,"+findtxt+"\ntry again ",QMessageBox::Ok,QMessageBox::Abort);
if(btn == QMessageBox::Ok){
text->moveCursor(QTextCursor::Start);
slotFind();
}
}
}
}
这是我写的方法,至于LZ另外的需求应该很容易实现了。。。
QString findtxt = editFind->text();
if(findtxt.isEmpty()){
QMessageBox::warning(this,tr("warning"),tr("No input"));
}else{
text->moveCursor(QTextCursor::Start);
if(!text->find(findtxt)){
QMessageBox::StandardButton btn;
btn = QMessageBox::information(this,tr("Find"),"cannot find,"+findtxt+"\ntry again ",QMessageBox::Ok,QMessageBox::Abort);
if(btn == QMessageBox::Ok){
text->moveCursor(QTextCursor::Start);
slotFind();
}
}
}
}
这是我写的方法,至于LZ另外的需求应该很容易实现了。。。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询