Results 1 to 9 of 9

Thread: construction of classes within classes

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #7
    Join Date
    Dec 2010
    Posts
    31
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    9
    Thanked 1 Time in 1 Post

    Default Re: construction of classes within classes

    HI high_flyer.

    This is all the code from the header file (including the previously discussed attempts at creating nested classes and some function defs):

    Qt Code:
    1. #ifndef ATTEMPT1_H
    2. #define ATTEMPT1_H
    3.  
    4. //#include <QWidget>
    5. //#include <iostream>
    6. //#include <fstream>
    7. //#include <string>
    8. //#include <vector>
    9. //#include <windows.h>
    10. //#include <QTextEdit>
    11. //#include <QString>
    12. #include <QFileDialog>
    13. //using namespace std;
    14. //#include <QtCore/QFile>
    15. //#include <QtCore/QTextStream>
    16. void FileOpen(QString fileName, QVector<double>& x, QVector<QVector<double> >& y); // this is using pointers for output
    17. void FiCalc(double lambda, double TwoThetaMin, double TwoThetaMax);
    18. QList<QList<int> > Combinations(int a, int b, int c,int aa,int bb,int cc);
    19. QList<double> AtomicScattering(QString Symbol,QList<float> dSpace);
    20. namespace Ui {
    21. class attempt1;
    22. }
    23.  
    24. class attempt1 : public QWidget
    25. {
    26. Q_OBJECT
    27.  
    28. public:
    29. explicit attempt1(QWidget *parent = 0);
    30. ~attempt1();
    31.  
    32. private:
    33. Ui::attempt1 *ui;
    34.  
    35. private slots:
    36. void on_save_clicked();
    37. void on_run_clicked();
    38. void on_load_clicked();
    39. };
    40.  
    41. #endif // ATTEMPT1_H
    To copy to clipboard, switch view to plain text mode 


    Qt Code:
    1. class atom
    2. {
    3. public:
    4. QString type;
    5. };
    6.  
    7.  
    8. class data
    9. {
    10. //int size;
    11. public:
    12. QString name; //string for standard name from CIF
    13. // QList < QList <QList<float> > >xyz; //3d array for XYZ values from CIF
    14. // data(int);
    15. int size;
    16. double aSide;
    17. double bSide;
    18. double cSide;
    19. double alpha;
    20. double beta;
    21. double gamma;
    22. double volume;
    23. QList<float> dSpace; //use a float as we only want to compare to 8 significant figures
    24. QList<QList<int> > hkl;
    25. QList<float> TwoTheta;
    26. QList<float> I;
    27. atom atom1;
    28. atom atom2;
    29.  
    30. };
    To copy to clipboard, switch view to plain text mode 
    The code im using in the cpp file id just what you wrote below:

    Qt Code:
    1. QMap<QString,atom*> m_mapAtoms;
    2. atom *pAtom = new atom;
    3. //Storing
    4. m_mapAtoms["atom1"] = pAtom;
    5. //using
    6. pAtom = m_mapAtoms["atom1"];
    To copy to clipboard, switch view to plain text mode 

    Is this the information you need?

    thanks

    Matt


    Added after 19 minutes:


    Sorry high_flyer I just realised i didnt include <QMap> (im still getting used to including things as in matlab you don't do this!).

    I will have a look at QMap now - in your opinion is this the best way to organize data sets each containing lots of different data types?

    Thanks for your help again!

    Matt
    Last edited by wysota; 10th January 2011 at 14:34. Reason: missing [code] tags

Similar Threads

  1. QT WMI Classes
    By justatiq in forum Qt Programming
    Replies: 31
    Last Post: 10th April 2011, 15:44
  2. Using WMI CLasses
    By newb in forum Newbie
    Replies: 1
    Last Post: 4th June 2010, 19:19
  3. Relationship b/w different classes
    By salmanmanekia in forum Newbie
    Replies: 0
    Last Post: 2nd June 2010, 18:24
  4. fax classes in qt
    By dyams in forum Qt Programming
    Replies: 5
    Last Post: 7th September 2007, 09:14

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.