Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 2

Qt-interest Archive, April 2008
QComboBox subclassing and QMouseEvent


Message 1 in thread

I have created a subclass of QComboBox in order to get Mouse Events, the
problem is that
the mouseDoubleClickEvent(QMouseEvent *) protected function of QWidget is
activated only
 when the cursor's position is at the right side of the QComboBox, namely
only when the user
presses the QComboBox's button which opens the drop list.
Any ideas of how could I get mouse events from the rest of the widget,(e.g.
when the user makes a
double click on the QComboBox's editable area?
Thanks in advance.

-- 
 [ signature omitted ] 

Message 2 in thread

Hi,

"Nikos Geronitidis" <geronik444@xxxxxxxxx> wrote in message 
news:2b0dc300804100459xd94fe3bpcc416490f2ec4319@xxxxxxxxxxxxxxxxx
> I have created a subclass of QComboBox in order to get Mouse Events, the 
> problem is that
> the mouseDoubleClickEvent(QMouseEvent *) protected function of QWidget is 
> activated only
> when the cursor's position is at the right side of the QComboBox, namely 
> only when the user
> presses the QComboBox's button which opens the drop list.

> Any ideas of how could I get mouse events from the rest of the 
> widget,(e.g. when the user makes a
> double click on the QComboBox's editable area?
> Thanks in advance.
The editable area is a QLineEdit, to which you can get a reference using 
QComboBox::lineEdit(). I guess you have two options:
1) install an event filter on the line edit to catch the event you want, or
2) Subclass QLineEdit as well, and provide your own line edit to your 
subclassed combo box using setLineEdit.

HTH,

André 

--
 [ signature omitted ] 

Message 3 in thread

Thanks for the advice, i chose to subclass the QLineEdit. I think that
installing an event filter would be a faster way to do the same thing..

On Thu, Apr 10, 2008 at 3:50 PM, André Somers <andre@xxxxxxxxxxxxxxxx>
wrote:

> Hi,
>
> "Nikos Geronitidis" <geronik444@xxxxxxxxx> wrote in message
> news:2b0dc300804100459xd94fe3bpcc416490f2ec4319@xxxxxxxxxxxxxxxxx
>
>  I have created a subclass of QComboBox in order to get Mouse Events, the
> > problem is that
> > the mouseDoubleClickEvent(QMouseEvent *) protected function of QWidget
> > is activated only
> > when the cursor's position is at the right side of the QComboBox, namely
> > only when the user
> > presses the QComboBox's button which opens the drop list.
> >
>
>  Any ideas of how could I get mouse events from the rest of the
> > widget,(e.g. when the user makes a
> > double click on the QComboBox's editable area?
> > Thanks in advance.
> >
> The editable area is a QLineEdit, to which you can get a reference using
> QComboBox::lineEdit(). I guess you have two options:
> 1) install an event filter on the line edit to catch the event you want,
> or
> 2) Subclass QLineEdit as well, and provide your own line edit to your
> subclassed combo box using setLineEdit.
>
> HTH,
>
> André
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
>


-- 
 [ signature omitted ]