Really New to QT and finding problem in very basics
Hi,
I am very new to Qt and am finding problem in the very basics of the Signals and Slots.
How to we connect a button click signal with my own slot.
What i did was that with the help of QT Designer i made a page with 2 buttons and one lineEdit. Now the first button was connected to the MainWindow with the clicked signal and the close slot.
it read as:
connect(button,SIGNAL(clicked()),MainWindow,SLOT(c lose()));
now what i want is that when i click the second button then it should display me a line on the lineEdit.
For that i created a class called Action.h and declared a slot in there. Then i made an action.cpp and defined the slot there.
Now is the problem? How do i get this slot connected to the clicked() signal of the button. Where should I write the connect statement which would connect the click of the button to the desired user-defined slot.
Thanking you,
Kapil
1 Attachment(s)
Re: Really New to QT and finding problem in very basics
hi,
here i am attaching the code with the message. It conatins: ui file, action.h and action.cpp file, main.cpp and the sigform.h..
i am not able to find what is the error that it contains. Please tell me why is it not working..
thanking you,
Kapil
Re: Really New to QT and finding problem in very basics
As far as I can tell, you connect pushbutton2 to close() and you connected pushbutton1 to signal clicked to pushbutton2... neither calls your action class
Re: Really New to QT and finding problem in very basics
In action.cpp replace your connect on next
Code:
connect(mw->pushButton, SIGNAL(clicked()), SLOT(actionSlot()));
Re: Really New to QT and finding problem in very basics
Quote:
Originally Posted by zlatko
In action.cpp replace your connect on next
Code:
connect(mw->pushButton, SIGNAL(clicked()), SLOT(actionSlot()));
I replaced the connect with the connect you asked me to in the action.cpp stil its not working.. nothing comes on the lineEdit when i press the button.
How to print anything on the lineEdit when i click on the pushButton...
Thanking you..
Kapil
Re: Really New to QT and finding problem in very basics
Quote:
Originally Posted by ReilenBlaeyze
As far as I can tell, you connect pushbutton2 to close() and you connected pushbutton1 to signal clicked to pushbutton2... neither calls your action class
Hi ReilenBlaeyze,
From where should i call the actionClass.. I want the PushButton clicked signal to get recognized.. So far no action is being taken on the click button.. what i thought was that when i click the first button, the second click will be called and it will exit...
or i will change the connect to another statement as told above and still no output is shown on the lineEdit.. so how should i instantiate the ActionClass ?
Kapil
Re: Really New to QT and finding problem in very basics
This is a double thread. Would the author please decide to post in only one of the threads? Thank you.
Re: Really New to QT and finding problem in very basics
Quote:
Originally Posted by wysota
This is a double thread. Would the author please decide to post in only one of the threads? Thank you.
I am sorry.. I basically got confused that in which thread i should post my problem.. Then i thought that my porblem is that of a newbie so i should rather post the thread in the newbie.. Didnt know how to move the thread from there..
Thank you
Kapil