This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Display a cursor on QTextEdit in QT4.8.5



Hello all,

The board details are :

Target : Ti AM335x startkit

SDK : 8

Host OS : ubuntu 14.04 LTS

I am trying to get a Cursor display on this board with the help of QT.Apparently it seems to be very hard to get a simple IBeam Cursor.

The Code is quite simple :

#include <QLabel>
#include <QFont>
#include <QtGui>
#include <QPixmap>
#include <QTextEdit>
#include <QTextCursor>
#include <QLineEdit>

int main( int argc, char **argv ) {
    QApplication app( argc, argv );

    MainWindow w;
    w.setWindowFlags(Qt::Window | Qt::FramelessWindowHint);
    w.setStyleSheet("background-color: yellow;");


    QTextEdit *txt = new QTextEdit();
    txt->setWindowFlags(Qt::Window | Qt::FramelessWindowHint);
    txt->setFocus();
    txt->setStyleSheet("background-color: rgba(255, 255, 255,      200);");
    txt->setGeometry(10,20,100,30);


    QTextCursor cursor = QTextCursor(txt->document());
    cursor.insertText("Text 1");
    cursor.beginEditBlock();
    // OR
    //In your case, either methods below will work since the text has been inserted already
    //cursor.movePosition(QTextCursor::End);
    //cursor.movePosition(QTextCursor::Start);

    txt->show();

    return app.exec();
  }

But I am unable to see the cursor. Could any one help on this >