
Originally Posted by
showhand
How can I get column number in a line??
try
int QTextCursor:
osition () const

Originally Posted by
showhand
I used QTextCursor movePositions(QTextCursor::Left),movePositions(QTe xtCursor::Right).But there comes a problem!
when i press left button , the return value of movePositions(QTextCursor::Right) is true.
Shouldn't your code be something like
{
if(e->key() == Qt::Key_Left){
column_num_--;
}
}
else if(e->key() == Qt::Key_Right){
column_num_++;
}
}
}
void textEdit::keyPressEvent(QKeyEvent *e)
{
QTextCursor cursor = textEdit->textCursor();
if(e->key() == Qt::Key_Left){
if(movePositions(QTextCursor::Left)){
column_num_--;
}
}
else if(e->key() == Qt::Key_Right){
if(movePositions(QTextCursor::Right)){
column_num_++;
}
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks