Model View Tutorial Part1 CVirtualCdRack/de: Difference between revisions
Jump to navigation
Jump to search
AutoSpider (talk | contribs) (Add "cleanup" tag) |
m (Wieland moved page Qt german-Model View Tutorial Teil1 CVirtualCdRack to Model View Tutorial Part1 CVirtualCdRack/de: not english) |
||
(One intermediate revision by one other user not shown) | |||
Line 23: | Line 23: | ||
# <div class="de1"> <span class="sy0">:</span> [http://doc.qt.io/QMainWindow.html <span class="kw5">QMainWindow</span>]<span class="br0">(</span>parent<span class="br0">)</span></div> | # <div class="de1"> <span class="sy0">:</span> [http://doc.qt.io/QMainWindow.html <span class="kw5">QMainWindow</span>]<span class="br0">(</span>parent<span class="br0">)</span></div> | ||
# <div class="de1"><span class="br0">{</span></div> | # <div class="de1"><span class="br0">{</span></div> | ||
# <div class="de1"> <span class="kw1">for</span><span class="br0">(</span><span class="kw4">int</span> i <span class="sy0">=</span> <span class="nu0">0</span><span class="sy0">;</span> i <span class="sy0"> | # <div class="de1"> <span class="kw1">for</span><span class="br0">(</span><span class="kw4">int</span> i <span class="sy0">=</span> <span class="nu0">0</span><span class="sy0">;</span> i <span class="sy0"><</span> MaxRecentFiles<span class="sy0">;</span> <span class="sy0">++</span>i<span class="br0">)</span></div> | ||
# <div class="de2"> m_recentFileActs<span class="br0">[</span>i<span class="br0">]</span> <span class="sy0">=</span> <span class="nu0">0</span><span class="sy0">;</span></div> | # <div class="de2"> m_recentFileActs<span class="br0">[</span>i<span class="br0">]</span> <span class="sy0">=</span> <span class="nu0">0</span><span class="sy0">;</span></div> | ||
# <div class="de1"> setWindowIcon<span class="br0">(</span>[http://doc.qt.io/QIcon.html <span class="kw5">QIcon</span>]<span class="br0">(</span><span class="st0">":/images/VirtualCdRack.png"</span><span class="br0">)</span><span class="br0">)</span><span class="sy0">;</span></div> | # <div class="de1"> setWindowIcon<span class="br0">(</span>[http://doc.qt.io/QIcon.html <span class="kw5">QIcon</span>]<span class="br0">(</span><span class="st0">":/images/VirtualCdRack.png"</span><span class="br0">)</span><span class="br0">)</span><span class="sy0">;</span></div> | ||
Line 38: | Line 38: | ||
# <div class="de1"> m_model <span class="sy0">=</span> <span class="kw1">new</span> CdModel<span class="br0">(</span>m_data<span class="sy0">,</span> <span class="kw1">this</span><span class="br0">)</span><span class="sy0">;</span></div> | # <div class="de1"> m_model <span class="sy0">=</span> <span class="kw1">new</span> CdModel<span class="br0">(</span>m_data<span class="sy0">,</span> <span class="kw1">this</span><span class="br0">)</span><span class="sy0">;</span></div> | ||
# <div class="de1"> m_view <span class="sy0">=</span> <span class="kw1">new</span> QTableView<span class="sy0">;</span></div> | # <div class="de1"> m_view <span class="sy0">=</span> <span class="kw1">new</span> QTableView<span class="sy0">;</span></div> | ||
# <div class="de1"> m_view<span class="sy0">- | # <div class="de1"> m_view<span class="sy0">-></span><span class="me3">setModel</span><span class="br0">(</span>m_model<span class="br0">)</span><span class="sy0">;</span></div> | ||
# <div class="de2"> m_view<span class="sy0">- | # <div class="de2"> m_view<span class="sy0">-></span><span class="me3">setAlternatingRowColors</span><span class="br0">(</span><span class="kw2">true</span><span class="br0">)</span><span class="sy0">;</span></div> | ||
# <div class="de1"> setCentralWidget<span class="br0">(</span>m_view<span class="br0">)</span><span class="sy0">;</span></div> | # <div class="de1"> setCentralWidget<span class="br0">(</span>m_view<span class="br0">)</span><span class="sy0">;</span></div> | ||
# <div class="de1"> </div> | # <div class="de1"> </div> | ||
Line 47: | Line 47: | ||
# <div class="de1"> createStatusBar<span class="br0">(</span><span class="br0">)</span><span class="sy0">;</span></div> | # <div class="de1"> createStatusBar<span class="br0">(</span><span class="br0">)</span><span class="sy0">;</span></div> | ||
# <div class="de1"> </div> | # <div class="de1"> </div> | ||
# <div class="de1"> <span class="kw2">connect</span><span class="br0">(</span><span class="sy0">& | # <div class="de1"> <span class="kw2">connect</span><span class="br0">(</span><span class="sy0">&</span>m_data<span class="sy0">,</span> SIGNAL<span class="br0">(</span>contentsChanged<span class="br0">(</span><span class="br0">)</span><span class="br0">)</span><span class="sy0">,</span> <span class="kw1">this</span><span class="sy0">,</span> SLOT<span class="br0">(</span>documentWasModified<span class="br0">(</span><span class="br0">)</span><span class="br0">)</span><span class="br0">)</span><span class="sy0">;</span></div> | ||
# <div class="de1"><span class="br0">}</span></div> | # <div class="de1"><span class="br0">}</span></div> | ||
Line 56: | Line 56: | ||
<div class="cpp-qt geshi"> | <div class="cpp-qt geshi"> | ||
# <div class="de1"><span class="sy0"> | # <div class="de1"><span class="sy0"><</span>?xml version<span class="sy0">=</span><span class="st0">"1.0"</span> encoding<span class="sy0">=</span><span class="st0">"UTF-8"</span>?<span class="sy0">></span></div> | ||
# <div class="de1"><span class="sy0"> | # <div class="de1"><span class="sy0"><!</span>DOCTYPE CdRack<span class="sy0">></span></div> | ||
# <div class="de1"><span class="sy0"> | # <div class="de1"><span class="sy0"><</span>CdRack version<span class="sy0">=</span><span class="st0">"1.0"</span><span class="sy0">></span></div> | ||
# <div class="de1"> <span class="sy0"> | # <div class="de1"> <span class="sy0"><</span>CD title<span class="sy0">=</span><span class="st0">"On and On"</span> author<span class="sy0">=</span><span class="st0">"Fiddler's Green"</span> genre<span class="sy0">=</span><span class="st0">"Irish Folk"</span> year<span class="sy0">=</span><span class="st0">"1997"</span><span class="sy0">></span></div> | ||
# <div class="de2"> <span class="sy0"> | # <div class="de2"> <span class="sy0"><</span>CD title<span class="sy0">=</span><span class="st0">"Von Spitzbuben und anderen Halunken"</span> author<span class="sy0">=</span><span class="st0">"Schandmaul"</span> genre<span class="sy0">=</span><span class="st0">"Mittelalter-Rock"</span> year<span class="sy0">=</span><span class="st0">"2001"</span><span class="sy0">></span></div> | ||
# <div class="de1"> <span class="sy0"> | # <div class="de1"> <span class="sy0"><</span>CD title<span class="sy0">=</span><span class="st0">"Look Sharp"</span> author<span class="sy0">=</span><span class="st0">"Roxette"</span> genre<span class="sy0">=</span><span class="st0">"Rock"</span> year<span class="sy0">=</span><span class="st0">"1988"</span><span class="sy0">></span></div> | ||
# <div class="de1"> <span class="sy0"> | # <div class="de1"> <span class="sy0"><</span>CD title<span class="sy0">=</span><span class="st0">"Oceanborn"</span> author<span class="sy0">=</span><span class="st0">"Nightwish"</span> genre<span class="sy0">=</span><span class="st0">"Hardrock"</span> year<span class="sy0">=</span><span class="st0">"1998"</span><span class="sy0">></span></div> | ||
# <div class="de1"><span class="sy0"> | # <div class="de1"><span class="sy0"></</span>CdRack<span class="sy0">></span></div> | ||
# <div class="de1"><span class="sy0">--</span></div> | # <div class="de1"><span class="sy0">--</span></div> | ||
Latest revision as of 13:00, 26 May 2015
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. |
Table of Content
↑Ü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.
- {
- for(int i = 0; i < MaxRecentFiles; ++i)
- m_recentFileActs[i] = 0;
- init();
- setCurrentFile("");
- readSettings();
- }
- void VirtualCdRack::init()
- {
- m_isUntitled = true;
- m_model = new CdModel(m_data, this);
- m_view = new QTableView;
- m_view->setModel(m_model);
- m_view->setAlternatingRowColors(true);
- setCentralWidget(m_view);
- createActions();
- createMenus();
- createToolBars();
- createStatusBar();
- connect(&m_data, SIGNAL(contentsChanged()), this, SLOT(documentWasModified()));
- }
Struktur der XML-Datei mit den CDs
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE CdRack>
- <CdRack version="1.0">
- <CD title="On and On" author="Fiddler's Green" genre="Irish Folk" year="1997">
- <CD title="Von Spitzbuben und anderen Halunken" author="Schandmaul" genre="Mittelalter-Rock" year="2001">
- <CD title="Look Sharp" author="Roxette" genre="Rock" year="1988">
- <CD title="Oceanborn" author="Nightwish" genre="Hardrock" year="1998">
- </CdRack>
- --
**