Hi,

I am a newbie to QT. I am trying a new application.
To start with, I am trying to display a cursor on QText Edit box.

The sample code is here :


This is my main.cpp file

Qt Code:
  1. #include "mainwindow.h"
  2. #include <QApplication>
  3. #include <QLabel>
  4. #include <QFont>
  5. #include <QtGui>
  6. #include <QPixmap>
  7. #include "usb-serial-app.h"
  8. #include <QTextEdit>
  9. #include <QTextCursor>
  10.  
  11.  
  12. int main(int argc, char *argv[])
  13. {
  14. QApplication a(argc, argv);
  15. QTextEdit *txt = new QTextEdit();
  16. txt->setText("Text 1");
  17. txt->setWindowFlags(Qt::Window | Qt::FramelessWindowHint);
  18. txt->setAutoFillBackground(true);
  19. txt->setStyleSheet("background-color: cyan;color : Brown;");
  20. txt->setFont(QFont("Arial", 10, QFont::Bold));
  21. txt->setAlignment(Qt::AlignCenter);
  22. txt->setGeometry(10,20,100,30);
  23.  
  24.  
  25. QTextCursor cursor(txt->textCursor());
  26. cursor.movePosition(QTextCursor::End, QTextCursor::MoveAnchor);
  27. txt->setTextCursor(cursor);
  28.  
  29. txt->show();
  30. return a.exec();
  31. }
To copy to clipboard, switch view to plain text mode 


Now the problem is, I am unable to display a cursor in the QTextEdit box.
Please help me.

I need to set the cursor blinking too.
I am using QT4.8.5

Thanks a lot.