Search This Blog

Saturday, June 27, 2009

Qt Tutorial Notes



source : http://code.google.com/p/mixtools/source/browse/#svn/trunk/qt/tutorial/tutorial
http://doc.trolltech.com/4.3/tutorial.html

T4:
  • qApp is a global variable
  • Put widget on heap, so Qt can manage the memory for you
T5:
  • treat layout as the parent of widgets being enclosed
  • How to overflow?
T6:
T7:
  • Signal can connect to signal: so you fire another signal.
  • Two ways to fire a signal: 1. signal connect to signal 2. directly fire it with emit
  • Cannot treat signal as slot
  • Signal is automatically generated by MOC (meta-object compiler), so do not implement it yourself, or you will get duplicate definition.
  • The Q_OBJECT macro must be used in all subclass of QObject, or the signal/slot will not work. Put the Q_OBJECT in the header file, and put the .h file in .pro file. This way qmake can search source and header files for the Q_Object macro. It will generate build instruction for moc.
  • slots can be public, protected, and private
  • To declare signal, just do "signals:"
T8:
  • setFocus()
  • setFocusProxy()
  • QString::Number() convert number to string
  • use "&" to set the button shortcut with Alt
T9:
  • Understand The Coordinate System of Qt
  • QRect: upper-left + width + height
  • drawPie: 0 is 3 o'clock, and draws counter-clockwise
  • QPainter::rotate(): on coordinate, and counter-clockwise
  • QTimer::start(int millisecs interval), stop(), isActive()
  • QTimer::singleShot(600000, &app, SLOT(quit()));
T11:
  • Understand save() and restore()

No comments: