Diana Papukchieva
Diana Papukchieva

Reputation: 145

QList in classes with QT Creator/c++

How can I make a QList so,that this list could contain information from more than one class (the classes are operated by two Map-Containers)?

These are my 4 classes:

Class for a lecture:

  class Veranstaltung
    {
    private:
       QMap<QString, LV >myLV; 
    public:
    Veranstaltung() {}
    void listLV(QTextStream& out) const; 
    ...
   };

    #endif // 

Class for the professorships

    LIST_H

     class ProfessurList
    {
    private:
        QMap<QString, Professur> myProfessuren; 
    public:
        ProfessurList() {} //kann man weglassen
        void addProf(QTextStream& in,QTextStream& out);
        void listProf(QTextStream& out) const; //Warum const?
       ...
    };

    #endif // PROFLIST_H

Another class for the lectures,where private and public are defined:

#ifndef LV_H
#define LV_H

class LV
{
private:
    QString myNummer;
    QString myBezeichnung;
    QString myTyp;
public:
    LV(const QString& nummer, const QString& bezeichnung, const QString& typ):
        myNummer(nummer), myBezeichnung(bezeichnung), myTyp(typ)

    {}
    QString nummer() const { return myNummer;}

    ...
};
QTextStream& operator<<(QTextStream& out, const LV& l); 

#endif // LV_H

Another class for the proffessorships where private and pubic are defined:

  #ifndef PROF_H
    #define PROF_H


    class Professur
    {
    private:
    QString myKuerzel;
    QString myName;
    QString myLehrstuhlinhaber;
    public:
    Professur(const QString& kuerzel, const QString& name, const QString& lehrstuhlinhaber):
        myKuerzel(kuerzel), myName(name), myLehrstuhlinhaber(lehrstuhlinhaber)
    {}

   ...
    };
    QTextStream& operator<<(QTextStream& out, const Professur& pr);

    #endif // PROF_H

Upvotes: 1

Views: 784

Answers (1)

kajojeq
kajojeq

Reputation: 904

Can't you simply create struct with X object? Like:

Struct ProfessorsAndLecturs
{
   Veranstaltung v;
   LEctures l;
   ...
};
ProfessorsAndLecturs pal;
pal.v = ...;
pal.l = ...;

QList<ProfessorsAndLecturs> list;
list.append(pal);

and later:

list.at(0).l;
etc.

If it's what you ask for.

Upvotes: 1

Related Questions