PDA

View Full Version : Add some function to reimplement method



Pablik
24th June 2012, 20:33
Hi
I want add:


if( !anchorAt( e->pos() ).isEmpty() )
QMessageBox::information(0,"",anchorAt( e->pos() ));

to orginal(default, not edited) method "mouseDoubleClickEvent" in qtextedit.

If i make my own method


void MyTextEdit::mouseDoubleClickEvent(QMouseEvent *e)
{
if( !anchorAt( e->pos() ).isEmpty() )
QMessageBox::information(0,"",anchorAt( e->pos() ));
}

then default(if you double click on char then selected all word) will be not work

So if i want add(not edit) then i will be have to make somting like this


void MyTextEdit::mouseDoubleClickEvent(QMouseEvent *e)
{
//i have to finde default code mouseDoubleClickEventand and past here

if( !anchorAt( e->pos() ).isEmpty() )
QMessageBox::information(0,"",anchorAt( e->pos() ));
}


Somebody know faster way to do this , without copy code from default method ??

wysota
24th June 2012, 20:38
<facepalm/> Call the base class implementation... This is basic C++...

Pablik
24th June 2012, 20:51
then i will by have to make new method xx()


MyTextEdit::xx(QMouseEvent *e)
{
mouseDoubleClickEvent(e)
if( !anchorAt( e->pos() ).isEmpty() )
QMessageBox::information(0,"",anchorAt( e->pos() ));
}


but now how tu set methos xx() to make on doubleclick
in constructor
connect(mouse, Signal (double click), this , slot(xx())) ???

wysota
24th June 2012, 21:01
No, you will not have to make a new method.


void MyTextEdit::mouseDoubleClickEvent(QMouseEvent *e) {
QTextEdit::mouseDoubleClickEvent(e);
}

Pablik
24th June 2012, 21:09
ok thx i dont know that