Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. International
  3. German
  4. Einstieg in Model-View-Konzept
Forum Updated to NodeBB v4.3 + New Features

Einstieg in Model-View-Konzept

Scheduled Pinned Locked Moved German
109 Posts 10 Posters 103.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    Wolf P.
    wrote on last edited by
    #81

    Nun bin ich durch, allerdings erst mal mit dem Lesen/Überarbeiten. Ein paar typographische Konventionen sollten wir vielleicht mal ausarbeiten, damit Bezüge auf Klassen, Methoden, Objekte im Fließtext ausreichend deutlich werden.

    Übrigens: für den Einstieg in MV(D) halte ich es inhaltlich und vom Niveau her für ganz brauchbar.
    (die o.g. Formsachen zu Lesbarkeit und Navigation sollten wir wirklich noch verbessern)

    1 Reply Last reply
    0
    • G Offline
      G Offline
      giesbert
      wrote on last edited by
      #82

      Hi Wolf,

      danke für das Feedback. Werde mich demnächst mal dran machen, weiterzubauen.

      Zwecks den downloads, hast du da was sinnvolles, wo wir beide sachen hinlegen können?
      ansonsten muss ich in google documents nochmal buddeln....

      Nokia Certified Qt Specialist.
      Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

      1 Reply Last reply
      0
      • G Offline
        G Offline
        giesbert
        wrote on last edited by
        #83

        [quote author="Wolf P." date="1299071815"]Nun bin ich durch, allerdings erst mal mit dem Lesen/Überarbeiten. Ein paar typographische Konventionen sollten wir vielleicht mal ausarbeiten, damit Bezüge auf Klassen, Methoden, Objekte im Fließtext ausreichend deutlich werden.
        [/quote]

        Wenn du muße hast ;-) lass dir was einfallen. Ich werde erstmal den rest machen, ich denke, mit genauer aufteilung etc können wir auch am schluss machen, oder?

        Nokia Certified Qt Specialist.
        Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

        1 Reply Last reply
        0
        • W Offline
          W Offline
          Wolf P.
          wrote on last edited by
          #84

          Ja, Struktur und Lesefluss können wir noch ein bisschen schieben. Wohin mit den zips? Tja, muss ich wohl noch überlegen.
          Sollte man vielleicht einen Pool für Qt-Beispielprogramme bei SourceForge registrieren?

          Das wäre vielleicht eine Frage an die "Unabhängigen Entwickler":http://developer.qt.nokia.com/groups/independent_developers ;-)

          1 Reply Last reply
          0
          • G Offline
            G Offline
            giesbert
            wrote on last edited by
            #85

            Eher beta forum, oder?
            ist ein allgemeines problem, da bei DevNet nix abgelegt werden darf... Genauso wie bilder etc...

            Nokia Certified Qt Specialist.
            Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

            1 Reply Last reply
            0
            • T Offline
              T Offline
              thorben
              wrote on last edited by
              #86

              Hallo zusammen,

              freut mich, dass das Projekt vorerst nur auf Eis liegt. Im Prinzip sind in diesem Tutorial ja die Aspekte enthalten, die das "MV-Programming" ausmachen.
              Was mir in der Doku auffällt ist das die Beispiele meist nur für einfache Sachen gelten (klar sollte mitunter ja auch genügen), aber gerade was das Drag&Drop angeht, wenn ich z. B. in von ViewA etwas in ViewB droppe, was kein Puzzleteil ist, sondern die Darstellung einer Datei, fände ich es z. B praktisch, wenn man die Koordination dieser beiden Teile noch aufnehmen konnte. Also das Drop als ein physikalisches Kopieren.
              Könnte mir das als Erstellen einer Playlist vorstellen(Speichern und auslesen in XML-Datei). Der Drop ergänzt dann die vorher geparste XML-Datei und kopiert den Track an die korrekte Stelle...
              Vielleciht ist das ja sogar im D&D-Teil dieses Tutorials so oder so ähnlich angedacht...

              Gruß Thorben

              It's time to ... whatever

              1 Reply Last reply
              0
              • G Offline
                G Offline
                giesbert
                wrote on last edited by
                #87

                Hi Thorben,

                ich werde demnächst erstmal mit Teil 3 weitermachen.
                Wenn du Ideen hast, einfach endweder hier oder als seite im Wiki ablegen. Die besten ideen gewinnen. Man muss nur immer bedenken, es sollen die Prinzipien gezeigt werden, nicht die Endstufe :-))

                Nokia Certified Qt Specialist.
                Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                1 Reply Last reply
                0
                • G Offline
                  G Offline
                  giesbert
                  wrote on last edited by
                  #88

                  Hi,

                  die sourcen liegen jetzt auf Gitoious, Teil 3 ist programmiert und ich fange mit der Beschreibung an

                  Nokia Certified Qt Specialist.
                  Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                  1 Reply Last reply
                  0
                  • G Offline
                    G Offline
                    giesbert
                    wrote on last edited by
                    #89

                    So, die Beschreibung ist fertig, war nicht allzu viel.
                    Ich bitte um Kritik, Vorschläge etc.

                    Nokia Certified Qt Specialist.
                    Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                    1 Reply Last reply
                    0
                    • T Offline
                      T Offline
                      thorben
                      wrote on last edited by
                      #90

                      Hi,
                      nach einer etwäs längeren (leider unschönen) Auszeit...
                      wenn ich den ersten Teil des Tutorials durcharbeite, sollte doch shcon die XML-Datei angezeigt werden oder?
                      Wenn ich aber in den CdModel::data() einen Haltepunkt setzt springe ich dort nie rein, in CdModel::rowCount() oder so aber schon. Könnte ich dort noch etwas vergessen haben?

                      <code>
                      m_model = new CdModel(m_data, this);
                      m_view = new QTableView;
                      m_view->setModel(m_model);
                      m_view->setAlternatingRowColors(true);
                      setCentralWidget(m_view);
                      </code>

                      Die Spaltenüberschriften werden im View übrigens auch nicht angezeigt.
                      Ich vermute mal einen Flüchtigkeitsfehler meinerseits...

                      Gruß Thorben

                      It's time to ... whatever

                      1 Reply Last reply
                      0
                      • G Offline
                        G Offline
                        giesbert
                        wrote on last edited by
                        #91

                        Wenn ich das noch richtig weiß, sind die screen shots direkt aus der applikation...
                        Hast du den code übernommen oder 1:1 das beispiel gebaut?

                        Nokia Certified Qt Specialist.
                        Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                        1 Reply Last reply
                        0
                        • T Offline
                          T Offline
                          thorben
                          wrote on last edited by
                          #92

                          Morgen,

                          habe den Code so übernommen, aber ich werde nochmal durchgehen woran es liegen könnte.
                          Also sollte die Applikation nach dem ersten Tutorial-Teil so wie im Screenshot arbeiten...

                          It's time to ... whatever

                          1 Reply Last reply
                          0
                          • G Offline
                            G Offline
                            giesbert
                            wrote on last edited by
                            #93

                            Eigentlich schon, wenn mich nicht alles täuscht...
                            Ich werds nochmal vorsichtshalber ausprobieren.

                            Nokia Certified Qt Specialist.
                            Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                            1 Reply Last reply
                            0
                            • G Offline
                              G Offline
                              giesbert
                              wrote on last edited by
                              #94

                              Hi,

                              Ich hab mir das zip file aus dem "Beispiel 1":https://docs.google.com/uc?id=0B8PL33_OKajLNmE4NjNiMTMtZmZjYS00NDQyLThiZjEtMTU3MDkwZTk2YmZk&export=download&authkey=CIbe3rQK&hl=en heruntergeladen und das gebaut und gestartet und das geht :-)

                              Nokia Certified Qt Specialist.
                              Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                              1 Reply Last reply
                              0
                              • T Offline
                                T Offline
                                thorben
                                wrote on last edited by
                                #95

                                Ok dann habe ich wohl sowas wie einen "Copy-Paste"-Fehler. Denn wenn ich z. B. das StringListModel aus dem Assistant verwende, funktioniert das auch. Gibt es einen Part (aus deiner Erfahrung) den man bei MV-Prog. gerne vergisst oder Fehler einbaut? Btw. unter welchen Umständen wird die data()-Methode nicht aufgerufen.

                                It's time to ... whatever

                                1 Reply Last reply
                                0
                                • G Offline
                                  G Offline
                                  giesbert
                                  wrote on last edited by
                                  #96

                                  Poste mal deinen model code, dann ist es vermuitlich leicht zu finden.
                                  data wird z.b. nicht aufgerufen, wenn rowCounf oder columnCount 0 liefern

                                  Nokia Certified Qt Specialist.
                                  Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                                  1 Reply Last reply
                                  0
                                  • T Offline
                                    T Offline
                                    thorben
                                    wrote on last edited by
                                    #97

                                    Hier noch cdmodel.cpp

                                    <code>
                                    #include <QtGui/QMessageBox>
                                    //lokale "includes"
                                    #include "cdmodel.h"

                                    CdModel::CdModel(CdRack& data, QObject* parent) : QAbstractItemModel(parent), m_data(data)
                                    {
                                    connect(&m_data, SIGNAL(reset()), this, SLOT(reloead()));
                                    connect(&m_data, SIGNAL(inserted(int)), this, SLOT(inserted(int)));
                                    connect(&m_data, SIGNAL(inserted(int, int)), this, SLOT(inserted(int, int)));

                                    m_columns.append(tr("Title"));
                                    m_columns.append(tr("Author"));
                                    m_columns.append(tr("Genre"));
                                    m_columns.append(tr("Year"));
                                    }
                                    QModelIndex CdModel::index(int row, int column, const QModelIndex &parent) const
                                    {
                                    //if(!parent.isValid())
                                    if(parent.isValid()) //Evtl. muss hier negiert werden
                                    {
                                    return QModelIndex();
                                    }

                                    if((0 <= row) && (row < rowCount()) &&
                                    (0 <= column) && (column < columnCount()))
                                    {
                                    return createIndex(row, column); //Index für Zugriff von außen erstellen
                                    }
                                    return QModelIndex();
                                    }
                                    QModelIndex CdModel::parent(const QModelIndex &child) const
                                    {
                                    return QModelIndex();
                                    }

                                    int CdModel::rowCount(const QModelIndex &parent) const
                                    {
                                    //QMessageBox::information(0, tr(""), tr("in CdModel::rowCount"));
                                    return m_data.size();
                                    }
                                    int CdModel::columnCount(const QModelIndex &parent) const
                                    {

                                    //QMessageBox::information(0, tr(""), tr("in CdModel::columnCount"));
                                    //if(!parent.isValid())
                                    if(parent.isValid()) //Evtl. muss das negiert werden ?????
                                    {
                                    return 0;
                                    }
                                    return m_columns.count();
                                    }
                                    QVariant CdModel::data(const QModelIndex &index, int role) const
                                    {
                                    QMessageBox::information(0, tr(""), tr("in CdModel::data()"));
                                    if(!index.isValid())
                                    {
                                    return QVariant();
                                    }
                                    if(Qt::DisplayRole == role)
                                    {
                                    const CdDisk& rDisk = m_data.at(index.row());
                                    switch(index.column())
                                    {
                                    case 0:
                                    return rDisk.m_title;
                                    break;
                                    case 1:
                                    return rDisk.m_author;
                                    break;
                                    case 2:
                                    return rDisk.m_genre;
                                    break;
                                    case 3:
                                    return rDisk.m_year;
                                    break;
                                    }
                                    }
                                    return QVariant();
                                    }
                                    QVariant CdModel::headerData(int section, Qt::Orientation orientation, int role) const
                                    {
                                    if( (Qt::DisplayRole == role) && (Qt::Horizontal == orientation) &&
                                    (0 <= section) && (section < columnCount()))
                                    {
                                    return m_columns.at(section);
                                    }
                                    return QVariant();
                                    }

                                    void CdModel::reload()
                                    {
                                    reset();
                                    }
                                    void CdModel::inserted(int nPosition)
                                    {
                                    //TODO
                                    }
                                    void CdModel::inserted(int nFirst, int nLast)
                                    {
                                    //TODO
                                    }
                                    </code>

                                    It's time to ... whatever

                                    1 Reply Last reply
                                    0
                                    • G Offline
                                      G Offline
                                      giesbert
                                      wrote on last edited by
                                      #98

                                      Benutz bitte mal das original beispiel projekt und teste, ob das bei dir geht.
                                      Evtl hast du im header auch irgendwo ein const zuviel / zuwenig etc...

                                      Spontan sehe ich keinen fehler. Oder du postest mal deinen gesamten code via pastebin oder so gitorious oder so

                                      Nokia Certified Qt Specialist.
                                      Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                                      1 Reply Last reply
                                      0
                                      • T Offline
                                        T Offline
                                        thorben
                                        wrote on last edited by
                                        #99

                                        ORiginal-Projekt geht!
                                        Habe bei mir nochmal gesucht und den Fehler gefunden:
                                        -> rowCount() lieferte 0
                                        Evtl. wg. dieser Zeile:
                                        <code>
                                        connect(&m_data, SIGNAL(reset()), this, SLOT(reloead()));
                                        </code>

                                        Habe aus reloead() ein reloead() gemacht und es ging!

                                        It's time to ... whatever

                                        1 Reply Last reply
                                        0
                                        • T Offline
                                          T Offline
                                          thorben
                                          wrote on last edited by
                                          #100

                                          Ups,

                                          sollte reload() heißen

                                          It's time to ... whatever

                                          1 Reply Last reply
                                          0

                                          • Login

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Users
                                          • Groups
                                          • Search
                                          • Get Qt Extensions
                                          • Unsolved