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

Monday, January 2nd 2012, 9:54am

how to use Qt ui element in QTextCursor

i am using QTextCursor
i want to use QT ui here
i am currently in mainwindow.cpp
ui->text element as its cursor
i have done this

QTextCursor cur();
cur().block(ui->text->cursor());

any one who could tell how to use ui->text here
i googled a lot asked on chat no anwser

2

Monday, January 2nd 2012, 12:37pm

Are you sure you have this?

QTextCursor cur();

That will not make a variable so I think you are ignoring some compiler warnings later on.
Correct is

Source code

1
QTextCursor cur;


Have you read the documents?
http://developer.qt.nokia.com/doc/qt-4.8…rsor.html#block
QTextCursor::block()

block() does not take any arguments but you are giving it some. Again, this should give you compiler error.

what class is ui->text????
If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

3

Monday, January 2nd 2012, 1:24pm

yes iread the link many times
secondly
ui->text
means the text element in qt ui

4

Monday, January 2nd 2012, 11:32pm

You read the docs? Do you understand them? block() does not take any arguments but you are giving it some - why?

lets try this one again:
what class is ui->text?
If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

5

Tuesday, January 3rd 2012, 5:26am

see the files
ubuntu has attached the following file:
  • 5.zip (4.62 kB - 2 times downloaded - latest: Jan 7th 2014, 2:41am)

6

Tuesday, January 3rd 2012, 11:03am

don't you know how to answer? If you don't, then you need to get to grips with the basics of c++ first. How well do you know c++?

QTextCursor cursor = ui->text->textCursor();
If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.