[Qt-interest] Problems with `password dialog' (Detailed)

Aaron Lewis aaron.lewis1989 at gmail.com
Thu Mar 11 01:47:33 CET 2010


Here's some more information:
   
  Actually i'm writing a Mysql Front End , when user triggered the
`Connection' action ,
 
  I'd like to show up a new Dialog , and let user type in informations
(kinds of username , passwd , hostname e.g)

  When she clicked on some button (e.g Yes) , dialog is closed ,  data
format is checked (isValid)
   then these information are transfered back to MainWindow (class qsqlcc)

  Now i'll be able to make connection between my program and mysql server

That's what i'm doing ..

Appreciate your help ;-)

Tibor Kiss wrote:
> 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
> <mailto: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 <mailto:Qt-interest at trolltech.com>
>     http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>   


-- 
Best Regards,
Aaron Lewis - PGP: 0x4A6D32A0
FingerPrint EA63 26B2 6C52 72EA A4A5 EB6B BDFE 35B0 4A6D 32A0
irc: A4r0n on freenode




More information about the Qt-interest-old mailing list