[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyQt] 'clicked' parameter in QPushButton's constructor
From:       Phil Thompson <phil () riverbankcomputing ! com>
Date:       2019-05-08 16:04:13
Message-ID: 2c5f8ec04091d59c9c4a463d4d3fbdce () riverbankcomputing ! com
[Download RAW message or body]

On 08/05/2019 16:48, Zhao Lee wrote:
> While if I replace
> button = QPushButton("Click me",clicked=say_hello)
> with
> button = QToolButton(triggered=say_hello)
> then the slot won't be called , why ?

Because the QToolButton triggered signal doesn't do the same thing as 
the QPushButton clicked signal.

Phil

> At 2019-05-08 16:51:31, "Phil Thompson" <phil@riverbankcomputing.com> 
> wrote:
> > On 08/05/2019 09:07, Zhao Lee wrote:
> > > I can connect slot to QPushButton's clicked signal in its constructor
> > > this way
> > > button = QPushButton("Click me",clicked=say_hello)
> > > It worked ! Test example as following:
> > > 
> > > 
> > > import sys
> > > from PyQt5.QtWidgets import *
> > > def say_hello():
> > > print("Button clicked, Hello!")
> > > # Create the Qt Application
> > > app = QApplication(sys.argv)
> > > # Create a button, connect it and show it
> > > button = QPushButton("Click me",clicked=say_hello)
> > > # button = QToolButton("Click me", clicked=say_hello)
> > > # button.clicked.connect(say_hello)
> > > button.show()
> > > # Run the main Qt loop
> > > app.exec_()
> > > 
> > > 
> > > However , there seems no parameter named 'clicked' in QPushButton's
> > > constructor as described in the doc  , what's the working mechanism
> > > behind ? How do I know which parameters I could pass to the
> > > constructor?
> > 
> > https://www.riverbankcomputing.com/static/Docs/PyQt5/signals_slots.html#connecting-signals-using-keyword-arguments
> >  
> > Phil

_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
https://www.riverbankcomputing.com/mailman/listinfo/pyqt


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic