Qt chap4<br />2011/02/23 - Browny<br />
Spreadsheet<br />
Outline<br />4.1 The Central Widget<br />4.2 Subclassing QTableWidget<br />4.3 Loading and Saving<br />4.4 Implementing th...
The central widget<br />
The central widget<br />標準Qt窗口 widget<br />QTableWidget, QTextEdit<br />功能如文件載入和儲存,必須在其他地方實現 (Qmain Window 的 subclass)<br ...
main.cpp<br />
mainwindow.cpp<br />
Outline<br />4.1 The Central Widget<br />4.2 Subclassing QTableWidget<br />4.3 Loading and Saving<br />4.4 Implementing th...
QTableWidget, QTableWidgetItem<br />Item class : 純數據類,並非繼承自 QObject,不能擁有signal, slot,也沒有使用 Q_OBJECT macro<br />
const member variable(int)<br />Spreadsheet.h<br />
spreadsheet.cpp<br />允許矩行框選<br />QAbstractItemView<br />QTableView<br />setSelectionMode()<br />
Spreadsheet::clear()<br />QTableWidget 由多個子窗口 widget 所組成<br />QAbstractItemView<br />QAbstractScrollArea<br />
Outline<br />4.1 The Central Widget<br />4.2 Subclassing QTableWidget<br />4.3 Loading and Saving<br />4.4 Implementing th...
QFile, QDataStream, (QTextStream)<br />各版本二進制表達方式不一定相同<br />檔頭 (識別檔案)<br />沙漏鼠標<br />
Outline<br />4.1 The Central Widget<br />4.2 Subclassing QTableWidget<br />4.3 Loading and Saving<br />4.4 Implementing th...
Edit Menu<br />::paste( )<br />::copy( )<br />把字串用 ‘n’ 分行<br />
Outline<br />4.1 The Central Widget<br />4.2 Subclassing QTableWidget<br />4.3 Loading and Saving<br />4.4 Implementing th...
Other Menu<br />4.5 一開頭講 spreadsheet 變更後的自動刷新,關於 setDirty() 機制可以留待 4.6 釐清<br />
Spreadsheet::sort()<br />仿函數 functor<br />把選取的資料存到Qlist<QStringList> 當中<br />根據  compare 決定如何排序<br />
SpreadsheetCompare<br />Override operator()<br />可擁有屬性<br />
::operator()<br />參考 圖3.14 下方,keys 和 ascending 用來決定以哪一欄為主要/次要 排序依據。<br />
Outline<br />4.1 The Central Widget<br />4.2 Subclassing QTableWidget<br />4.3 Loading and Saving<br />4.4 Implementing th...
setDirty() ?<br />
Spreadsheet::text()<br />
Where is Cell::text() ?<br />QTableWidgetItem provided convenient function text() = data.toSrting()<br />
Cell::value()<br />Got It !<br />把表達式轉乘計算結果,與介面無關,跳過 XD<br />
Conclusion<br />複雜的繼承體系,也許先了解基礎抽象類比較有個底<br />參考 Qt Class 大全<br />http://trinity.pearsoncomputing.net/docs/qt4/classes.html...
Thank You Q&A<br />
Upcoming SlideShare
Loading in …5
×

[C++ GUI Programming with Qt4] chap4

1,022 views

Published on

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,022
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
21
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

[C++ GUI Programming with Qt4] chap4

  1. 1. Qt chap4<br />2011/02/23 - Browny<br />
  2. 2. Spreadsheet<br />
  3. 3. Outline<br />4.1 The Central Widget<br />4.2 Subclassing QTableWidget<br />4.3 Loading and Saving<br />4.4 Implementing the Edit Menu<br />4.5 Implementing the Other Menu<br />4.6 Subclassing QTableWidgetItem<br />
  4. 4. The central widget<br />
  5. 5. The central widget<br />標準Qt窗口 widget<br />QTableWidget, QTextEdit<br />功能如文件載入和儲存,必須在其他地方實現 (Qmain Window 的 subclass)<br />自定義窗口 widget<br />帶布局管理器的普通 widget<br />切分窗口 (Qsplitter)<br />多文檔介面<br />
  6. 6. main.cpp<br />
  7. 7. mainwindow.cpp<br />
  8. 8. Outline<br />4.1 The Central Widget<br />4.2 Subclassing QTableWidget<br />4.3 Loading and Saving<br />4.4 Implementing the Edit Menu<br />4.5 Implementing the Other Menu<br />4.6 Subclassing QTableWidgetItem<br />
  9. 9. QTableWidget, QTableWidgetItem<br />Item class : 純數據類,並非繼承自 QObject,不能擁有signal, slot,也沒有使用 Q_OBJECT macro<br />
  10. 10. const member variable(int)<br />Spreadsheet.h<br />
  11. 11. spreadsheet.cpp<br />允許矩行框選<br />QAbstractItemView<br />QTableView<br />setSelectionMode()<br />
  12. 12. Spreadsheet::clear()<br />QTableWidget 由多個子窗口 widget 所組成<br />QAbstractItemView<br />QAbstractScrollArea<br />
  13. 13. Outline<br />4.1 The Central Widget<br />4.2 Subclassing QTableWidget<br />4.3 Loading and Saving<br />4.4 Implementing the Edit Menu<br />4.5 Implementing the Other Menu<br />4.6 Subclassing QTableWidgetItem<br />
  14. 14. QFile, QDataStream, (QTextStream)<br />各版本二進制表達方式不一定相同<br />檔頭 (識別檔案)<br />沙漏鼠標<br />
  15. 15. Outline<br />4.1 The Central Widget<br />4.2 Subclassing QTableWidget<br />4.3 Loading and Saving<br />4.4 Implementing the Edit Menu<br />4.5 Implementing the Other Menu<br />4.6 Subclassing QTableWidgetItem<br />
  16. 16. Edit Menu<br />::paste( )<br />::copy( )<br />把字串用 ‘n’ 分行<br />
  17. 17. Outline<br />4.1 The Central Widget<br />4.2 Subclassing QTableWidget<br />4.3 Loading and Saving<br />4.4 Implementing the Edit Menu<br />4.5 Implementing the Other Menu<br />4.6 Subclassing QTableWidgetItem<br />
  18. 18. Other Menu<br />4.5 一開頭講 spreadsheet 變更後的自動刷新,關於 setDirty() 機制可以留待 4.6 釐清<br />
  19. 19. Spreadsheet::sort()<br />仿函數 functor<br />把選取的資料存到Qlist<QStringList> 當中<br />根據 compare 決定如何排序<br />
  20. 20. SpreadsheetCompare<br />Override operator()<br />可擁有屬性<br />
  21. 21. ::operator()<br />參考 圖3.14 下方,keys 和 ascending 用來決定以哪一欄為主要/次要 排序依據。<br />
  22. 22. Outline<br />4.1 The Central Widget<br />4.2 Subclassing QTableWidget<br />4.3 Loading and Saving<br />4.4 Implementing the Edit Menu<br />4.5 Implementing the Other Menu<br />4.6 Subclassing QTableWidgetItem<br />
  23. 23. setDirty() ?<br />
  24. 24. Spreadsheet::text()<br />
  25. 25. Where is Cell::text() ?<br />QTableWidgetItem provided convenient function text() = data.toSrting()<br />
  26. 26. Cell::value()<br />Got It !<br />把表達式轉乘計算結果,與介面無關,跳過 XD<br />
  27. 27. Conclusion<br />複雜的繼承體系,也許先了解基礎抽象類比較有個底<br />參考 Qt Class 大全<br />http://trinity.pearsoncomputing.net/docs/qt4/classes.html<br />善用 IDE 的 Type Hierarchy 功能<br />
  28. 28. Thank You Q&A<br />

×