Qt-interest Archive, February 2007
Right click over QHeader?
Message 1 in thread
Hello,
I need to setup an action over right click on a vertical qheader of a qtable. Can somebody give me an idea on the easiest way to achieve this?
Thanks in advance.
---zdruid
___________________________________________________________
The all-new Yahoo! Mail goes wherever you go - free your email address from your Internet provider. http://uk.docs.yahoo.com/nowyoucan.html
--
[ signature omitted ]
Message 2 in thread
Zed Druid wrote:
>Hello,
>
> I need to setup an action over right click on a vertical qheader of a qtable. Can somebody give me an idea on the easiest way to achieve this?
>
>Thanks in advance.
>
>---zdruid
>
>
>
QHeaderView *headerView = header();
connect(headerView, SIGNAL(sectionDoubleClicked ( int) ), this,
SLOT(setRowOrColumn(int)));
Then, do what you want in the slot: setRowOrColumn(int)
Lingfa
--
[ signature omitted ]
Message 3 in thread
----- Original Message ----
From: lingfa <lingfa@xxxxxxxxxxxx>
To: Zed Druid <zdruid@xxxxxxxxx>
Cc: qt-interest@xxxxxxxxxxxxx
Sent: Thursday, 1 February, 2007 5:15:44 PM
Subject: Re: Right click over QHeader?
Zed Druid wrote:
>Hello,
>
> I need to setup an action over right click on a vertical qheader of a qtable. Can somebody give me an idea on the easiest way to achieve this?
>
>Thanks in advance.
>
>---zdruid
>
QHeaderView *headerView = header();
connect(headerView, SIGNAL(sectionDoubleClicked ( int) ), this,
SLOT(setRowOrColumn(int)));
Then, do what you want in the slot: setRowOrColumn(int)
------------
I am sorry I forgot to say that I need to this on Qt3, and here I don't have QHeaderView but QHeader and this class hasn't a signal for the right click as I can see on the documentation.
Thanks.
---zdruid
___________________________________________________________
New Yahoo! Mail is the ultimate force in competitive emailing. Find out more at the Yahoo! Mail Championships. Plus: play games and win prizes.
http://uk.rd.yahoo.com/evt=44106/*http://mail.yahoo.net/uk
--
[ signature omitted ]
Message 4 in thread
Zed Druid wrote:
>----- Original Message ----
>From: lingfa <lingfa@xxxxxxxxxxxx>
>To: Zed Druid <zdruid@xxxxxxxxx>
>Cc: qt-interest@xxxxxxxxxxxxx
>Sent: Thursday, 1 February, 2007 5:15:44 PM
>Subject: Re: Right click over QHeader?
>
>Zed Druid wrote:
>
>
>
>>Hello,
>>
>> I need to setup an action over right click on a vertical qheader of a qtable. Can somebody give me an idea on the easiest way to achieve this?
>>
>>Thanks in advance.
>>
>>---zdruid
>>
>>
>>
> QHeaderView *headerView = header();
> connect(headerView, SIGNAL(sectionDoubleClicked ( int) ), this,
>SLOT(setRowOrColumn(int)));
>Then, do what you want in the slot: setRowOrColumn(int)
>------------
>I am sorry I forgot to say that I need to this on Qt3, and here I don't have QHeaderView but QHeader and this class hasn't a signal for the right click as I can see on the documentation.
>Thanks.
>
>
Overwrite contextMenuEvent() which is invoked by right click.
--
[ signature omitted ]
Message 5 in thread
Hello,
You could install an event filter on the header and check for a right click.
It works well for me.
In a subclass of QTable:
verticalHeader()->installEventFilter( this );
And in eventFilter( QObject * obj, QEvent * e ):
QHeader * vertHeader = verticalHeader();
if ( obj == vertHeader ) {
if ( e && e->type() == QEvent::MouseButtonPress ) { // mouse press
event?
QMouseEvent *mEvent = (QMouseEvent*)e;
if ( mEvent && mEvent->button() == Qt::RightButton ) { // right
button?
DoHeaderContextMenuEvent( (QContextMenuEvent*)e);
...
Pam
...
"Zed Druid" <zdruid@xxxxxxxxx> wrote in message
news:480720.88591.qm@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
----- Original Message ----
From: lingfa <lingfa@xxxxxxxxxxxx>
To: Zed Druid <zdruid@xxxxxxxxx>
Cc: qt-interest@xxxxxxxxxxxxx
Sent: Thursday, 1 February, 2007 5:15:44 PM
Subject: Re: Right click over QHeader?
Zed Druid wrote:
>Hello,
>
> I need to setup an action over right click on a vertical qheader of a
> qtable. Can somebody give me an idea on the easiest way to achieve this?
>
>Thanks in advance.
>
>---zdruid
>
QHeaderView *headerView = header();
connect(headerView, SIGNAL(sectionDoubleClicked ( int) ), this,
SLOT(setRowOrColumn(int)));
Then, do what you want in the slot: setRowOrColumn(int)
------------
I am sorry I forgot to say that I need to this on Qt3, and here I don't have
QHeaderView but QHeader and this class hasn't a signal for the right click
as I can see on the documentation.
Thanks.
---zdruid
___________________________________________________________
New Yahoo! Mail is the ultimate force in competitive emailing. Find out more
at the Yahoo! Mail Championships. Plus: play games and win prizes.
http://uk.rd.yahoo.com/evt=44106/*http://mail.yahoo.net/uk
--
[ signature omitted ]
Message 6 in thread
----- Original Message ----
From: lingfa <lingfa@xxxxxxxxxxxx>
To: Zed Druid <zdruid@xxxxxxxxx>
Cc: qt-interest@xxxxxxxxxxxxx
Sent: Thursday, 1 February, 2007 5:44:33 PM
Subject: Re: Right click over QHeader?
Zed Druid wrote:
>----- Original Message ----
>From: lingfa <lingfa@xxxxxxxxxxxx>
>To: Zed Druid <zdruid@xxxxxxxxx>
>Cc: qt-interest@xxxxxxxxxxxxx
>Sent: Thursday, 1 February, 2007 5:15:44 PM
>Subject: Re: Right click over QHeader?
>
>Zed Druid wrote:
>
>>Hello,
>>
>> I need to setup an action over right click on a vertical qheader of a qtable. Can somebody give me an idea on the easiest way to achieve this?
>>
>>Thanks in advance.
>>
>>---zdruid
>>
> QHeaderView *headerView = header();
> connect(headerView, SIGNAL(sectionDoubleClicked ( int) ), this,
>SLOT(setRowOrColumn(int)));
>Then, do what you want in the slot: setRowOrColumn(int)
>------------
>I am sorry I forgot to say that I need to this on Qt3, and here I don't have QHeaderView but QHeader and this class hasn't a signal for the right click as I can see on the documentation.
>Thanks.
>
>
Overwrite contextMenuEvent() which is invoked by right click.
Ok, but I need to do it on QHeader which I know how to do, but then I need QTable uses my new QHeader, how can I do that?
I am sorry if this question is too simple. Thanks
--
[ signature omitted ]
Message 7 in thread
Zed Druid wrote:
>----- Original Message ----
>From: lingfa <lingfa@xxxxxxxxxxxx>
>To: Zed Druid <zdruid@xxxxxxxxx>
>Cc: qt-interest@xxxxxxxxxxxxx
>Sent: Thursday, 1 February, 2007 5:44:33 PM
>Subject: Re: Right click over QHeader?
>
>Zed Druid wrote:
>
>
>>----- Original Message ----
>>From: lingfa <lingfa@xxxxxxxxxxxx>
>>To: Zed Druid <zdruid@xxxxxxxxx>
>>Cc: qt-interest@xxxxxxxxxxxxx
>>Sent: Thursday, 1 February, 2007 5:15:44 PM
>>Subject: Re: Right click over QHeader?
>>
>>Zed Druid wrote:
>>
>>
> >
>
>
>>>Hello,
>>>
>>>I need to setup an action over right click on a vertical qheader of a qtable. Can somebody give me an idea on the easiest way to achieve this?
>>>
>>>Thanks in advance.
>>>
>>>---zdruid
>>>
>>>
>>>
>> QHeaderView *headerView = header();
>> connect(headerView, SIGNAL(sectionDoubleClicked ( int) ), this,
>>SLOT(setRowOrColumn(int)));
>>Then, do what you want in the slot: setRowOrColumn(int)
>>------------
>>I am sorry I forgot to say that I need to this on Qt3, and here I don't have QHeaderView but QHeader and this class hasn't a signal for the right click as I can see on the documentation.
>>Thanks.
>>
>>
>>
>>
>Overwrite contextMenuEvent() which is invoked by right click.
>
>Ok, but I need to do it on QHeader which I know how to do, but then I need QTable uses my new QHeader, how can I do that?
>
>
void QTableView::setHorizontalHeader ( MyHeaderView * header )
void QTableView::setVerticalHeader ( MyHeaderView * header )
--
[ signature omitted ]
Message 8 in thread
Thanks a lot Pam, this works excellent and also represent a solution to other problems I have.
----- Original Message ----
From: Pam <pwood@xxxxxxxxxxxx>
To: qt-interest@xxxxxxxxxxxxx
Sent: Thursday, 1 February, 2007 8:11:40 PM
Subject: Re: Right click over QHeader?
Hello,
You could install an event filter on the header and check for a right click.
It works well for me.
In a subclass of QTable:
verticalHeader()->installEventFilter( this );
And in eventFilter( QObject * obj, QEvent * e ):
QHeader * vertHeader = verticalHeader();
if ( obj == vertHeader ) {
if ( e && e->type() == QEvent::MouseButtonPress ) { // mouse press
event?
QMouseEvent *mEvent = (QMouseEvent*)e;
if ( mEvent && mEvent->button() == Qt::RightButton ) { // right
button?
DoHeaderContextMenuEvent( (QContextMenuEvent*)e);
...
Pam
...
"Zed Druid" <zdruid@xxxxxxxxx> wrote in message
news:480720.88591.qm@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
----- Original Message ----
From: lingfa <lingfa@xxxxxxxxxxxx>
To: Zed Druid <zdruid@xxxxxxxxx>
Cc: qt-interest@xxxxxxxxxxxxx
Sent: Thursday, 1 February, 2007 5:15:44 PM
Subject: Re: Right click over QHeader?
Zed Druid wrote:
>Hello,
>
> I need to setup an action over right click on a vertical qheader of a
> qtable. Can somebody give me an idea on the easiest way to achieve this?
>
>Thanks in advance.
>
>---zdruid
>
QHeaderView *headerView = header();
connect(headerView, SIGNAL(sectionDoubleClicked ( int) ), this,
SLOT(setRowOrColumn(int)));
Then, do what you want in the slot: setRowOrColumn(int)
------------
I am sorry I forgot to say that I need to this on Qt3, and here I don't have
QHeaderView but QHeader and this class hasn't a signal for the right click
as I can see on the documentation.
Thanks.
---zdruid
___________________________________________________________
New Yahoo! Mail is the ultimate force in competitive emailing. Find out more
at the Yahoo! Mail Championships. Plus: play games and win prizes.
http://uk.rd.yahoo.com/evt=44106/*http://mail.yahoo.net/uk
--
[ signature omitted ]