| Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date | |
| All threads index page 1 | |
I have a slot to handle the QTreeWidget::itemClicked signal.
I also want to find out which mouse button caused the signal to be emitted.
Using QApplication:mouseButtons() in my sample below always gives a
value of '0' for buttons.
The problem with using QApplication::mouseButtons() is that the
itemClicked signal is not emitted until the mouse button is released.
Any ideas on how to achieve this would be most appreciated.
void MyClass::handleItemClicked(QTreeWidgetItem *item, int column)
{
Qt::KeyboardModifiers modifiers = QApplication::keyboardModifiers();
Qt::MouseButtons buttons = QApplication::mouseButtons();
....
}
Thanks,
Mark
--
[ signature omitted ]
On Monday 04 June 2007, Mark Thompson wrote: > I have a slot to handle the QTreeWidget::itemClicked signal. > I also want to find out which mouse button caused the signal to be > emitted. > > Using QApplication:mouseButtons() in my sample below always gives a > value of '0' for buttons. > The problem with using QApplication::mouseButtons() is that the > itemClicked signal is not emitted until the mouse button is released. > > Any ideas on how to achieve this would be most appreciated. a) use itemPressed instead. b) additionally connect to itemPressed, remember the item and the mouse button, but don't do anything yet. In the handler for itemClicked compare the item with the one stored in itemPressed-handler and use the stored button value if they match. Warning: I just looked at the docu, I didn't try it. Konrad
Attachment:
Attachment:
pgpe9RC13xsji.pgp
Description: PGP signature
Message 3 in thread
Konrad,
Thanks; works perfectly!
Mark
Konrad Rosenbaum wrote:
> On Monday 04 June 2007, Mark Thompson wrote:
>
>> I have a slot to handle the QTreeWidget::itemClicked signal.
>> I also want to find out which mouse button caused the signal to be
>> emitted.
>>
>> Using QApplication:mouseButtons() in my sample below always gives a
>> value of '0' for buttons.
>> The problem with using QApplication::mouseButtons() is that the
>> itemClicked signal is not emitted until the mouse button is released.
>>
>> Any ideas on how to achieve this would be most appreciated.
>>
>
> a) use itemPressed instead.
>
> b) additionally connect to itemPressed, remember the item and the mouse
> button, but don't do anything yet. In the handler for itemClicked compare
> the item with the one stored in itemPressed-handler and use the stored
> button value if they match.
>
>
> Warning: I just looked at the docu, I didn't try it.
>
>
> Konrad
>
--
[ signature omitted ]
Message 4 in thread
Is this new to 4.2.3? I've got 4.2.2 and itemPressed doesn't pass a mouse
event.
Doc sais:
void QTreeWidget::itemPressed ( QTreeWidgetItem * item, int column )
[signal]
...and that's all I can connect to.
Met vriendelijke groet/With kind regards,
ir. Marc Oldenhof - Senior engineer Metrology
BrainCenter-Noord B.V.
Oliemolenstraat 5, 9203 ZN, Drachten, Netherlands
Phone: +31 512 59 2545
Fax: +31 512 59 2110
marc.oldenhof@xxxxxxxxxxx
http://pww.yellowpages.philips.com/YpMyProfile.do?authorCN=Marc+Oldenhof
qt-interest-request@xxxxxxxxxxxxx wrote on 04-06-2007 21:41:51:
> On Monday 04 June 2007, Mark Thompson wrote:
> > I have a slot to handle the QTreeWidget::itemClicked signal.
> > I also want to find out which mouse button caused the signal to be
> > emitted.
> >
> > Using QApplication:mouseButtons() in my sample below always gives a
> > value of '0' for buttons.
> > The problem with using QApplication::mouseButtons() is that the
> > itemClicked signal is not emitted until the mouse button is released.
> >
> > Any ideas on how to achieve this would be most appreciated.
>
> a) use itemPressed instead.
>
> b) additionally connect to itemPressed, remember the item and the mouse
> button, but don't do anything yet. In the handler for itemClicked
compare
> the item with the one stored in itemPressed-handler and use the stored
> button value if they match.
>
>
> Warning: I just looked at the docu, I didn't try it.
>
>
> Konrad
> [attachment "att7d7u0.dat" deleted by Marc Oldenhof/DTN/DAP/PHILIPS]