Model View Tutorial Part1 CVirtualCdRack/de: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
m (Wieland moved page Qt german-Model View Tutorial Teil1 CVirtualCdRack to Model View Tutorial Part1 CVirtualCdRack/de: not english) |
||
(4 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{{Cleanup | reason=Auto-imported from ExpressionEngine.}} | |||
<div class="factbox right"> | |||
===Table of Content=== | |||
* [[#453994a4a1b12fa9f20637bb33fc4d63|Die Klasse VirtualCdRack]] | |||
** [[#7ea8f52b947073e2281fe24121242836|Struktur der XML-Datei mit den CDs]] | |||
</div> | |||
[http://qt.io/groups/qt_german/wiki/Model_View_Tutorial ↑Übersicht Model/View Tutorial:CD Verwaltung↑]<br />[http://qt.io/groups/qt_german/wiki/Model_View_Tutorial_Teil1_CdRack Allgemeines: Klasse CdRack→] | [http://qt.io/groups/qt_german/wiki/Model_View_Tutorial ↑Übersicht Model/View Tutorial:CD Verwaltung↑]<br />[http://qt.io/groups/qt_german/wiki/Model_View_Tutorial_Teil1_CdRack Allgemeines: Klasse CdRack→] | ||
Line 6: | Line 17: | ||
Des weiteren hält sie eine Instanz der Datenklasse CdRack, eine Instanz des Datenmodells CdModel.<br /> Sie erstellt eine ''QTabelView''-Instanz und verbindet sie mit dem Modell. | Des weiteren hält sie eine Instanz der Datenklasse CdRack, eine Instanz des Datenmodells CdModel.<br /> Sie erstellt eine ''QTabelView''-Instanz und verbindet sie mit dem Modell. | ||
<div class="cpp-qt geshi"> | |||
# <div class="de1">VirtualCdRack<span class="sy0">::</span><span class="me2">VirtualCdRack</span><span class="br0">(</span>[http://doc.qt.io/QWidget.html <span class="kw5">QWidget</span>] <span class="sy0">*</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="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="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"> init<span class="br0">(</span><span class="br0">)</span><span class="sy0">;</span></div> | |||
# <div class="de1"> setCurrentFile<span class="br0">(</span><span class="st0">""</span><span class="br0">)</span><span class="sy0">;</span></div> | |||
# <div class="de1"> readSettings<span class="br0">(</span><span class="br0">)</span><span class="sy0">;</span></div> | |||
# <div class="de2"><span class="br0">}</span></div> | |||
# <div class="de1"> </div> | |||
# <div class="de1"> </div> | |||
# <div class="de1"><span class="kw4">void</span> VirtualCdRack<span class="sy0">::</span><span class="me2">init</span><span class="br0">(</span><span class="br0">)</span></div> | |||
# <div class="de1"><span class="br0">{</span></div> | |||
# <div class="de2"> m_isUntitled <span class="sy0">=</span> true<span class="sy0">;</span></div> | |||
# <div class="de1"> </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="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">-></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"> </div> | |||
# <div class="de1"> createActions<span class="br0">(</span><span class="br0">)</span><span class="sy0">;</span></div> | |||
# <div class="de1"> createMenus<span class="br0">(</span><span class="br0">)</span><span class="sy0">;</span></div> | |||
# <div class="de2"> createToolBars<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"> <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> | |||
==Struktur der <span class="caps">XML</span>-Datei mit den CDs== | ==Struktur der <span class="caps">XML</span>-Datei mit den CDs== | ||
** | <div class="cpp-qt geshi"> | ||
# <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"><!</span>DOCTYPE CdRack<span class="sy0">></span></div> | |||
# <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"><</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"><</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"><</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"><</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"></</span>CdRack<span class="sy0">></span></div> | |||
# <div class="de1"><span class="sy0">--</span></div> | |||
</div> | |||
<br /> ** |
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>
- --
**