[PyQt] Help with Login Dialog / QThread issues

Baz Walter bazwal at ftml.net
Mon Aug 8 15:58:04 BST 2011


On 08/08/11 14:58, Eric Frederich wrote:
> I'm just a little confused on what connections to make.
> I'm sure I could get something working but I'd be going about it the wrong way.
>
> Forget my original post.
>
> This is what I want.
> I want a login dialog with username, password and group.
> I want that dialog to stay up until the login is successful or user hits cancel.
> I have a QThread subclass for logging in.
> It emits either "success" or "fail", and with fail it provides some
> text feedback.
> When the login thread starts a progress bar should start animating.
>
> This is where I am completely lost as far as connections go.
> The QDialogButtonBox has accepted, rejected.
> The QDialog has accepted, rejected.
> My login thread has success, and fail.
> There are clicked() signals as well.
>
> Its not complicated, but I'm new to Qt and PyQt.
> I think I need someone to spell it out for me.

okay. in designer, open up View -> Signal/Slot Editor, remove the 
buttonBox.accepted() connection, and then re-compile.

next, in your LoginDialog class, rename your accept method to, say, 
handleAccepted, and connect it to the accepted() signal of the buttonBox:

     self.buttonBox.accepted.connect(self.handleAccepted)

finally, in handleAccepted, replace the thread connection with:

     self.lt.finished.connect(self.accept)

(obviously, i haven't tested this at all, but hopefully it will give you 
the general idea).



More information about the PyQt mailing list