[PyKDE] Using QFileDialog
Baz Walter
bazwal at ftml.net
Mon Jan 9 19:27:48 GMT 2006
On Monday 09 Jan 2006 16:12, piotr maliński wrote:
> I'm learning pyQT and I have a problem with QFileDialog - how can I
> get the selected filename? I've made a simple form: a pushbutton that
> onlick runs function "test" which opens the filedialog (in
> qtdesigner):
> ------------------------------
> void Form1::test()
> {
> a = QFileDialog(self)
> QObject.connect(a, SIGNAL('fileSelected()') ,self , SLOT('test2()'))
> a.show()
> }
> -------------------------------
> But when the widgets shows i get:
> QObject::connect: No such signal QFileDialog::fileSelected()
> QObject::connect: (sender name: 'unnamed')
> QObject::connect: (receiver name: 'Form1')
>
> test2 function looks like this:
> --------------------------------------
> void Form1::test2()
> {
> self.pushButton1.setText("aaaaaa")
> }
> --------------------------------------
> 1. how can I make it work?
> 2. how can I get the selected filename and display its name as
> pushButton1 text? Will something like: SLOT("test2(a.selectedFile())")
> work?
SLOT is only needed for pre-defined qt slots. When connecting to slots you
have created yourself, pass the python function object instead, like this:
void Form1::test()
{
a = QFileDialog(self)
QObject.connect(a, SIGNAL('fileSelected(const QString&)'), self.test2)
a.show()
}
HTH
--
Baz Walter
More information about the PyQt
mailing list