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:
- right click on the pushbutton. Select go to slot.
- Select clicked()
- 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.
- 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.
精彩评论