[c++ gui programming with qt4] chap6

Download [C++ GUI Programming with Qt4] chap6

If you can't read please download the document

Upload: picker-weng

Post on 19-May-2015

1.308 views

Category:

Documents


12 download

DESCRIPTION

C++ GUI Programming with Qt4 - Chap6

TRANSCRIPT

  • 1. Ch 6 Layout Management Author: Tony

2. Absolute Positioning

  • The user cannot resize the window

3. Some text may be truncated

  • Unusually large font

4. Translate into another language The widget might have inappropriate sizes 5. The positions and sizes must be calculated manually 6. resizeEvent

  • Set the widgets' geometries
  • reserve the extra space for ensuring the user resizes the widget smoothly

7. Layout Manager

  • QLayout
  • QHBoxLayout

8. QVBoxLayout 9. QGridLayout 10. Margin & Spacing

  • QLayout::setContentsMargins()

11. QLayout::setSpacing() 12. QGridLayout

  • Add widget with matrix type
  • layout->addWidget(widget, row, column, rowSpan, columnSpan);
  • rowSpan = 1

13. columnSpan = 1 addStretch()

  • Excess space between close button and help button

14. QSizePolicy 15. Preferred vs. Expanding

  • The excess space will give to theExpandingwidgets.

16. Preferredwidgets stay at their size hint. 17. MinimumExpanding & Ignored

  • They are used in older version of Qt

18. Replaced by

  • Expanding

19. ReimplementminimumSizeHint() 20. Stretch Factor

  • Two factors to define the expanding rate
  • QSizePolicy::setHorizontalStretch ( uchar stretchFactor )

21. QSizePolicy::setVerticalStretch ( uchar stretchFactor ) 22. QStackedLayout

  • Show the one of a set of
  • Child widgets

23. Pages The pages are numbered from 0 24. Make a specific child widget visible

  • setCurrentIndex()

25. An Example of Preferences Dialog QListWidget QStackedLayout 26. Splitters

  • Qsplitter class

27. Contain other widgets 28. Automatically placed side by side in the order in which they are created 29. An Example of Splitters 30. An Example of The Mail Client's Splitter Layout 31. An Example of The Mail Client's Splitter Layout (cont.)

  • User resizes a window, Qsplitter normally distributes the space
  • setStretchFactor()

32. Scrolling Areas

  • Simpler to use (comparison with QscrollBars)

33. Call setWidget() member function 34. setWidgetResizable() 35. ScrollBarPolicy

  • setHorizontalScrollBarPolicy()

36. setVerticalScrollBarPolicy() 37. 38. Dock Windows 39. Dock Windows (cont.) 40. Dock Windows (cont.)

  • QDockWidget class

41. SetFeatures()

  • movable, closable, and floatable

setAllowedAreas() 42. QMainWindow::setCorner() 43. Save the states

  • QMainWindow::saveState()

44. QMainWindow::restoreState() 45. Dock Windows (cont.) 46. Tool Bar 47. Tool Bar (cont.) 48. Tool Bar (cont.) 49. Multiple Documemt Interface (MDI) 50. MDI (cont.)

  • QMidArea class
  • Create it and make it central

51. MDI (cont.) 52. Qt-specific Command-Line Options

  • Options
  • style
  • motif, windows, and platinum

font 53. graphicssystem

  • raster, opengl

Arguments

  • QApplication::arguments()

54. Qt-specific Command-Line Options 55. Add a New Sub-window 56. Other Sub-window Operations

  • closeActiveSubWindow()

57. closeAllSubWindow() 58. tileSubWindow() 59. cascadeSubWindow()