You are not logged in.

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Thursday, June 11th 2015, 7:22am

I BeamCursor in QTextEdit widget

Hello all,

Thank you for going through this post. I am completely new to QT, please help me out.
I am using an Texas instrument AM335x startkit board for QT.

I have a specific requirement here :
1. I have a QTextEdit widget and a text is being displayed into it. I want the cursor to appear inside the QTextEdit widget.

Here is the code.


#include <QLabel>
#include <QFont>
#include <QtGui>
#include <QPixmap>
#include <QTextEdit>
#include <QTextCursor>
#include <QLineEdit>
#include "mainwindow.h"
#include <QCoreApplication>


Source code

1
2
3
4
5
int main(int argc, char *argv[]){        QApplication a(argc, argv);
	QTextEdit *txt = new QTextEdit();	QTextCursor cursor(txt->textCursor());    	txt->setFocus();    	txt->setGeometry(10,20,100,30);	txt->activateWindow();		txt->setText("  WELCOME  ");	txt->setTextCursor(cursor);	txt->ensureCursorVisible();        //QTextCursor cursor = QTextCursor(txt->document());    	//cursor.insertText("WELCOME");    	//cursor.beginEditBlock();
	//QCursor::setPos((txt->pos()+=QPoint(10,10)));	//cursor.movePosition(QTextCursor::End);        //cursor.movePosition(QTextCursor::Start);	//cursor.activateWindow();	        txt->show();
        return a.exec();
}



Here the cursor is not blinking inside the QTextEdit widget. Can anyone help me out.
Thank you