Model View Tutorial Part1 CVirtualCdRack/de

From Qt Wiki
Revision as of 13:00, 26 May 2015 by Wieland (talk | contribs) (Wieland moved page Qt german-Model View Tutorial Teil1 CVirtualCdRack to Model View Tutorial Part1 CVirtualCdRack/de: not english)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
This article may require cleanup to meet the Qt Wiki's quality standards. Reason: Auto-imported from ExpressionEngine.
Please improve this article if you can. Remove the {{cleanup}} tag and add this page to Updated pages list after it's clean.

↑Übersicht Model/View Tutorial:CD Verwaltung↑
Allgemeines: Klasse CdRack→

Die Klasse VirtualCdRack

Die Klasse VirtualCdRack bildet das Hauptfenster der Anwendung.
Sie erstellt die Menüs, Toolbars und die Statusbar.

Des weiteren hält sie eine Instanz der Datenklasse CdRack, eine Instanz des Datenmodells CdModel.
Sie erstellt eine QTabelView-Instanz und verbindet sie mit dem Modell.

  1. VirtualCdRack::VirtualCdRack(QWidget *parent)
  2.     : QMainWindow(parent)
  3. {
  4.     for(int i = 0; i < MaxRecentFiles; ++i)
  5.         m_recentFileActs[i] = 0;
  6.     setWindowIcon(QIcon(":/images/VirtualCdRack.png"));
  7.     init();
  8.     setCurrentFile("");
  9.     readSettings();
  10. }
  11.  
  12.  
  13. void VirtualCdRack::init()
  14. {
  15.     m_isUntitled = true;
  16.  
  17.     m_model = new CdModel(m_data, this);
  18.     m_view = new QTableView;
  19.     m_view->setModel(m_model);
  20.     m_view->setAlternatingRowColors(true);
  21.     setCentralWidget(m_view);
  22.  
  23.     createActions();
  24.     createMenus();
  25.     createToolBars();
  26.     createStatusBar();
  27.  
  28.     connect(&m_data, SIGNAL(contentsChanged()), this, SLOT(documentWasModified()));
  29. }

Struktur der XML-Datei mit den CDs

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE CdRack>
  3. <CdRack version="1.0">
  4.     <CD title="On and On" author="Fiddler's Green" genre="Irish Folk" year="1997">
  5.     <CD title="Von Spitzbuben und anderen Halunken" author="Schandmaul" genre="Mittelalter-Rock" year="2001">
  6.     <CD title="Look Sharp" author="Roxette" genre="Rock" year="1988">
  7.     <CD title="Oceanborn" author="Nightwish" genre="Hardrock" year="1998">
  8. </CdRack>
  9. --


**