Re: MouseEvent on QTextEdit
Its ok becouse when you catch your doubleclick text is not selected yet :rolleyes:
Re: MouseEvent on QTextEdit
hi,
I understood something. Generally when we double click in a text edit, we see that word being selected which is not happening in my application. Hence the if-condition fails and no output is printed on the console. And when I remove the if-condition, exiting of the program by reporting "Bus error" occurs because of the 7th line.
But that doesnot solve my problem . Can anyone help me in this regard?
Re: MouseEvent on QTextEdit
Dear Wysota sir,
You said that we can get the line by calculating the cursor positions.If it is so, please let me know the steps that I have to write to get the application working.It got struck up since morning just because of this :(
Regards,
Sarma.
Re: MouseEvent on QTextEdit
Quote:
Originally Posted by Sarma
Code:
int *para1,*para2,*index1,*index2;
if( te->hasSelectedText() )
{
system("echo mouse clicked");
te->getSelection(para1,index1,para2,index2,0);
}
This should be:
Code:
int para1, para2, index1, index2;
if( te->hasSelectedText() )
{
system("echo mouse clicked");
te->getSelection( ¶1, &index1, ¶2, &index2, 0 );
}
Otherwise QTextEdit::getSelection() will overwrite some random memory location which will cause a segmentation fault.
Re: MouseEvent on QTextEdit
hi jacek,
well, thats not the solution because when there is no text selected, u are not supposed to use getselection() method whatever may be the usage of its parameters.
I have found the solution to maximum extent but I couldnot make it till the end. The have changed the code like this:
Code:
int para
= te
->paragraphAt
(QCursor::pos());
// te is the textEdit object
But the thing is when I load some file into textedit, the cursor will be at the end of the textedit. So, at any time, the first line returns the last para number.
Now, Please tell me how to move the cursor to the place where Iam clicking the mouse.
Thanks and regards,
Sarma.
Re: MouseEvent on QTextEdit
Quote:
Originally Posted by Sarma
Now, Please tell me how to move the cursor to the place where Iam clicking the mouse.
Shouldn't this happen automatically?
Re: MouseEvent on QTextEdit
jacek,
Please don't pose those kind of questions, my dear. kindly tell the answer.
Re: MouseEvent on QTextEdit
Quote:
Originally Posted by Sarma
Please don't pose those kind of questions, my dear. kindly tell the answer.
Why? Is all you want is a fish?
QTextEdit provides such functionality out of the box. Why do you want to implement something that is already implemented?
Re: MouseEvent on QTextEdit
hi,
Yes, QTextEdit has got such kind of functionality. But I don't know why it is not happenning in my application. Iam showing you a part of my code:
Code:
if( e
->type
() == QEvent::MouseButtonDblClick ) {
int para1
= te
->paragraphAt
(QCursor::pos());
return true;
}
Now, when mouse is DoubleClicked, para1 is holding the number of the last line in the textedit(te). Therefore Iam unable to get any text in "line". Is there any method (or what is the possible step) that I can follow to make it working? :(
Thanks and Regards,
Sarma.
Re: MouseEvent on QTextEdit
Where is that code snippet located? Is it from event filter?
Re: MouseEvent on QTextEdit
see the thread by name "How to change paragraph number in QTextEdit?"
Re: MouseEvent on QTextEdit
Quote:
Originally Posted by Sarma
see the thread by name "How to change paragraph number in QTextEdit?"
But in what method that code snippet is located? And why did you open another thread, if it is the same problem?
Re: MouseEvent on QTextEdit
hi,
I think you didnot see the code correctly. There is only one if-condition , present in the code. And I have posted a new thread as It has become a different problem now.
regards,
Sarma.
Re: MouseEvent on QTextEdit
Quote:
Originally Posted by Sarma
There is only one if-condition , present in the code.
But in what method did you place that if statement?