[Qt-interest] Pls help w/ basic 'data' transfer from class to class

John McClurkin jwm at nei.nih.gov
Mon Jul 6 13:38:48 CEST 2009


S. Aguinaga wrote:
> 
> Hello Dear Fellows,
> 
> I am spending an unreasonable amount of time trying to: Pass Strings to 
> another Class to build another window.
> In other words, I extract two QStrings from a database, but now I want 
> to pass only this information to another class
> that builds another window using these strings. an I can't get pass the 
> errors  --So, I'm hoping one you can drop me a hint.
> 
> The first window prompts me for a userID, I authenticate it agai nst 
> records on the database, I want to use this ID in the next dialog window.
> The next dialog window will select another user from a table ( same 
> database, different table ) and then use these 2 strings through out 
> my application.
> 
> First string: 
> I tried line below in my main.cpp:
> 
> FirstWin *homeWindow = new FirstWin ( this, "userID");
> 
> ***** firstwin.h declares it as: 
> class FirstWin : public QMainWindow
> {
>     Q_OBJECT
> 
> public:
>    FirstWin(QWidget *parent = 0, const QString *); // 
> Or  FirstWin(QWidget *parent = 0, const char *);
If you want a default value for the parent argument, you need to place 
it second in the list, ie.
FirstWin(const QString *, QWidget *parent = 0);

> 
> 
> ***** firstwin.cpp implements it as:
> FirstWin:: FirstWin(QWidget *parent, const QString userID) : 
> QMainWindow(parent)
> {
>     qDebug() << userID << "\n";
>     ui.setupUi(this);
> 
> But, I get errors about 'this' being a non-member (blah, blah) and I 
> drop 'this', and just use in main.cpp FirstWin homeWindow("userID");
> 
> I also get errors.  
> Should I be using "class FirstWin : public QDialog in my header file? 
>  Any hints into getting this to work will be sincerely appreciated!!
> Thanks.
> 
> // Sal Aguinaga
> // Northwestern University
> 



More information about the Qt-interest-old mailing list