View Full Version : How to add contents into a QDialog or QMessageBox and display it?

19th December 2011, 08:31
Hi all,
I am new to Qt and i am trying to write click event for the QPushbutton.
In which when the user clicks on the push button it must display some contents in a dialog box.

for example: i am trying for: if the user clicks the button for the first time it should display 1 and when the button is clicked for the second time it should display 2 and so on.

It means whenever the user clicks on the push button the number should increase by 1.

Is there any sample coding or anyone can help me to come with the answer?


19th December 2011, 09:05
That is basic c++! Use a static variable which is increased when clicking the button. Use signal and slots and show the message box.

19th December 2011, 10:46
Thank you for your reply

Added after 1 14 minutes:

Could you help me with the code?

19th December 2011, 17:09
Could you help me with the code?

Answering this question is one or two lines of code. It is not going to help you to learn Qt if we write your code for you - you should study examples so you can learn how to write the code yourself.

Have you looked at any of the tutorials in the Qt Docs? Such as this one? Have you read any books that talk about Qt programming?