QTextCursor prev_Curosr=ui->Input->textCursor();
qDebug()<<prev_Curosr.position();
QTextCursor currentCurosr=prev_Curosr;
int num1=string_to_int(expr1);
int num2=string_to_int(expr2); /*计算结果*/
/* Display the result */
ui->Input->appendPlainText(QString::number(num1+num2));
qDebug()<<"Hello"<<currentCurosr.position()<<endl;
qDebug()<<prev_Curosr.position();
if(prev_Curosr.position()==prev_Curosr.position())
ui->Input->insertPlainText(QString("Hello world"));
return 0;
}
3
Hello 5
5
求问:为什么prev_Cursor currentCursor会在appendPlainText执行之后变成5,没道理呀
黄舟2017-04-17 13:00:54
The problem is solved, ask and answer your own questions.
TextCursor returns an absolute cursor, use
TextCursor.deleteChar()
setPos
position()
Function can solve it