开发者

QT signals & slots

How to use signal and slots for handling events i.e when a pushButton is clicked some number should be displayed in 开发者_StackOverflow社区QLineEdit.Just like in caluculator application when a number is clicked the corresponding is displayed .


connect a widget's signal to other's widget slot.

Signal = Emitted when the button (for instance) is pressed. Slot = called when a certain singal is fired, and this signal is connected to this slot.


If You use QtCreator here is the procedure:

  1. right click on the pushbutton. Select go to slot.
  2. Select clicked()
  3. QtCreator will open C++ editor with new empty member function defined that implements your slot. This function will be called whenever someone clicks this button.
  4. Now in this function you can call method of another widget ot modify its contants.

This book is quite good for starters:

http://www.amazon.com/Book-Qt-Art-Building-Applications/dp/1593271476/ref=sr_1_8?ie=UTF8&qid=1300905855&sr=8-8

Good luck.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜