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

Qt-interest Archive, January 2008
Overriding mouse clicks on title bars and in a QTreeWidget.


Message 1 in thread

I'm having two issues at the moment.

I want to override the doubleclick on the titlebar of a QDialog.  Both
an event filter and overriding the mouseDoubleClickEvent only apply to
the internal area of the dialog that is not the title bar or the outer
resizing frame.  Is there an easy way to catch a mouseclick on the
title bar of a QDialog?

In a slightly related problem i would like to override right clicking
in a QTreeWidget to show a popup menu like windows explorer.
QTreeWidget has a itemClicked Signal which only returns the
QTreeWidgetItem that was clicked and which column.  It does not
indicate which mouse button was used.   
I also tried overriding the eventfilter for the QTreeWidget but it
only applies to the border of the QTreeWidget.  I assume the internal
widgets are handing the event and not propogating it up.  Unfortunatly
you cannot install an event filter on a QTreeWidgetItem.
Is there a way to do this or do i have to start with a QTreeView and
not use the convienient QTreeWidget class?

Can someone please point me in the correct direction.

--
 [ signature omitted ] 

Message 2 in thread

> I want to override the doubleclick on the titlebar of a QDialog.  Both
> an event filter and overriding the mouseDoubleClickEvent only apply to
> the internal area of the dialog that is not the title bar or the outer
> resizing frame.  Is there an easy way to catch a mouseclick on the
> title bar of a QDialog?

Bad news. Window decoration is not provided by Qt but the underlying
window system.

> In a slightly related problem i would like to override right clicking
> in a QTreeWidget to show a popup menu like windows explorer.
> QTreeWidget has a itemClicked Signal which only returns the
> QTreeWidgetItem that was clicked and which column.  It does not
> indicate which mouse button was used.
> I also tried overriding the eventfilter for the QTreeWidget but it
> only applies to the border of the QTreeWidget.  I assume the internal
> widgets are handing the event and not propogating it up.  Unfortunatly
> you cannot install an event filter on a QTreeWidgetItem.
> Is there a way to do this or do i have to start with a QTreeView and
> not use the convienient QTreeWidget class?

Take a look at QWidget::contextMenuEvent() and QWidget::contextMenuPolicy.

-- 
 [ signature omitted ] 

Message 3 in thread

Kevin wrote:

> -----Original Message-----
> From: Kevin [mailto:spifffers@xxxxxxxxxxx] 
> Sent: Wednesday, 16 January 2008 05:05
> To: qt-interest@xxxxxxxxxxxxx
> Subject: Overriding mouse clicks on title bars and in a QTreeWidget.
> 
> I want to override the doubleclick on the titlebar of a QDialog.  Both
> an event filter and overriding the mouseDoubleClickEvent only apply to
> the internal area of the dialog that is not the title bar or the outer
> resizing frame.  Is there an easy way to catch a mouseclick on the
> title bar of a QDialog?

Hi Kevin, 

I haven't used it, but have a look at
QEvent::NonClientAreaMouseButtonDblClick. At least in Windows, the
'NonClient' events occur for the window decorations. 

Regards, 

Tony Rietwyk

--
 [ signature omitted ]