PDA

View Full Version : Simple click detection on QTextBroxser



Nyphel
10th April 2007, 11:34
Hello,

I've a very simple QDialog that holds only a QTextBrowser, in order to simulate the bubbles of my TrayIcon (Cause the showMessage() function of the QSystemTrayIcon shows nothing on Win2000 ;)).

I would like to detect when the user click the QTextBrowser, but I've seen no signals to listen.
I'm not sure this is possible... :confused:

Have you got an idea ?
Thanks :)

hickscorp
10th April 2007, 11:44
Hello,

QTextBrowser inherits QTextEdit, QTextEdit inherits QScrollView, QScrollView inherits from QFrame, QFrame inherits QWidget. All those class have usefull signals you can use:
- From QTextEdit, there is a signal named clicked from, another signal named doubleClicked.
- Also, if you dont want to use signal, you can implement QTextBrowser to your own class and inside use contentsMouseDoubleClickEvent(), contentsMouseMoveEvent(), contentsMousePressEvent(), contentsMouseReleaseEvent(). In your custom class you can overide those methods.

Hope this will help ^^
Pierre.

Nyphel
10th April 2007, 11:51
Thanks Pierre :)

I want to use my own class implementation, in effectly.
But, when I have a look to this page (http://doc.trolltech.com/4.2/qtextedit.html), Trolltech doesn't tell about the "clicked" signal :eek:

I'll try, and I'll seethe result :)

hickscorp
10th April 2007, 11:56
Hello again Nyphel (I guess we're both french ^^),

When you are at this page you told me, click on the "List of all members, including inherited members" link. It will lead there (http://doc.trolltech.com/4.2/qtextedit-members.html).

There you can see all events related to the object you're implementing, and one of them is mousePressEvent, another helpfull is mouseReleaseEvent. i believe with some workaround, you can use them to achieve what you're doing ^^ I'm not sure on how mouseReleaseEvent will behave, but probably as soon as the user releases his mouse button, the event is triggered. What you will have to see is, if the event is triggered if the mouse is still over the widget.

Pierre.

Nyphel
10th April 2007, 12:46
Oh yes... Thanks :)
That's seems to be exactly what I need !

And... I'm french too ^_^