Sending a Signal from a QTableWidget header

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Sending a Signal from a QTableWidget header

starglider.dev
Hi,
I need to open a dialog if the user click in the QTableWidget header.

Is it possible?
I search the documentation but didn't find a Signal to do that.

Thank you in advance.

_______________________________________________
PyQt mailing list    [hidden email]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Reply | Threaded
Open this post in threaded view
|

Re: Sending a Signal from a QTableWidget header

Hans-Peter Jansen-2
On Saturday 21 January 2012, 23:21:18 starglider.dev wrote:
> Hi,
> I need to open a dialog if the user click in the QTableWidget header.

There's no such class in PyQt (nor in Qt). If you mean QTable, then
QHeader.clicked() is proably, wat you're looking for.

Pete
_______________________________________________
PyQt mailing list    [hidden email]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Reply | Threaded
Open this post in threaded view
|

Re: Sending a Signal from a QTableWidget header

Hans-Peter Jansen-2
On Sunday 22 January 2012, 16:38:21 Hans-Peter Jansen wrote:
> On Saturday 21 January 2012, 23:21:18 starglider.dev wrote:
> > Hi,
> > I need to open a dialog if the user click in the QTableWidget
> > header.
>
> There's no such class in PyQt (nor in Qt). If you mean QTable, then
> QHeader.clicked() is proably, wat you're looking for.

Scratch that, I looked up the wrong docs.

Since QTableWidget inherits from QTableView, the
{horizontal,vertical}Header() methods return a QHeaderView instance,
which emits e.g. sectionPressed(int).

Sorry for the confusion.

Pete
_______________________________________________
PyQt mailing list    [hidden email]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Reply | Threaded
Open this post in threaded view
|

Re: Sending a Signal from a QTableWidget header

Hans-Peter Jansen-2
On Tuesday 24 January 2012, 00:37:31 starglider.dev wrote:
> Hi Pete,
> thank you for your help.
> I found the anwser in Mark Summerfield's book:

Good choice.

> chapter 14 in file ships-delegate.pyw
> Here is the code:
>             header = tableView.horizontalHeader()
>             self.connect(header, SIGNAL("sectionClicked(int)"),
>                          self.sortTable)

Better use new style signals'n'slots:

              header.sectionClicked.connect(self.sortTable)

Much easier, less typing and more secure, since it will traceback on
startup, if you fail to type the signal name correctly.

Pete

> jorge
>
> On 22 January 2012 15:57, Hans-Peter Jansen <[hidden email]> wrote:
> > On Sunday 22 January 2012, 16:38:21 Hans-Peter Jansen wrote:
> > > On Saturday 21 January 2012, 23:21:18 starglider.dev wrote:
> > > > Hi,
> > > > I need to open a dialog if the user click in the QTableWidget
> > > > header.
> > >
> > > There's no such class in PyQt (nor in Qt). If you mean QTable,
> > > then QHeader.clicked() is proably, wat you're looking for.
> >
> > Scratch that, I looked up the wrong docs.
> >
> > Since QTableWidget inherits from QTableView, the
> > {horizontal,vertical}Header() methods return a QHeaderView
> > instance, which emits e.g. sectionPressed(int).
> >
> > Sorry for the confusion.
> >
> > Pete
> > _______________________________________________
> > PyQt mailing list    [hidden email]
> > http://www.riverbankcomputing.com/mailman/listinfo/pyqt


_______________________________________________
PyQt mailing list    [hidden email]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt