Search This Blog

Saturday, June 27, 2009

Qt Tutorial Notes

source :

  • qApp is a global variable
  • Put widget on heap, so Qt can manage the memory for you
  • treat layout as the parent of widgets being enclosed
  • How to overflow?
  • 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:"
  • setFocus()
  • setFocusProxy()
  • QString::Number() convert number to string
  • use "&" to set the button shortcut with Alt
  • 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()));
  • Understand save() and restore()

No comments: