[Qt-interest] Problems with `password dialog'
Tibor Kiss
tibor at wiesen.at
Wed Mar 10 11:38:09 CET 2010
Well, the information is a bit short to analyse your problem.
First, some typo, I think if you have
qgetpass::qgetpass (QWidget *parent , QString *username , QString *passwd ,
QString *host)
then here, you should have a parent:
qgetpass *passDialog = new qgetpass(this, &_username,&_passwd,&_host);
So, regarding the password problem, I do it like this, it's very simple and
usefull:
class pass : public QDialog
{
Q_OBJECT
public:
pass (QWidget *parent = 0);
...
nothing extra here, some buttons, etc
...
};
pass::pass (QWidget *parent) : QDialog (parent)
{
... just set up the UI for the dialog
}
void pass::on_okbutton_clicked ()
{
... check the password ...
done(id); // return ID of the user
}
void pass::on_cancel_clicked ()
{
done(0);
}
And finally in the mainwindow:
...
pass *dialog = new pass (this);
int id = dialog->exec();
if (id == 0) return; // we don't have a positive authentication...
...
If you happen to make the password dialog more than once in your program,
you should think about it's destruction, because otherwise it will go out of
the memory only when you close your mainwindow. You can check QPointer types
for the safe delete methods.
2010/3/10 Aaron Lewis <aaron.lewis1989 at gmail.com>
> Hi,
> I have a main window, and i want to dynamically create a Dialog to
> get informations ( kinds of user-name , password e.g)
>
> I have two classes , qsqlcc and qgetpass.
>
> I tried some sample code:
>
> I) In class getpass , i tried to take advantage of construct
> function , tried to pass pointers to it:
> qgetpass::qgetpass (QWidget *parent , QString *username , QString
> *passwd , QString *host)
> ..
>
> II) In MainWindow , in some function
>
> qgetpass *passDialog = new qgetpass(&_username,&_passwd,&_host);
>
> I then will got empty strings . I thought i should use connections ,
> but i've got no ideas..
>
> Any ideas will appreciate .
>
> --
> Best Regards,
> Aaron Lewis - PGP: 0x4A6D32A0
> FingerPrint EA63 26B2 6C52 72EA A4A5 EB6B BDFE 35B0 4A6D 32A0
> irc: A4r0n on freenode
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100310/a2a38206/attachment.html
More information about the Qt-interest-old
mailing list