problem with userdefined slot definition in QT4.4.3
Hi,
- I created a project(LayoutDesign) in QT4.4.3,it created LayoutDesign.ui ,LayoutDesign.h,LayoutDesign.cpp and main.cpp file
- I opened the ui file using QTDesigner and i added 3 widgets(LineEdit1,Pushbutton,LineEdit2) on to it.
- my intention is when i click Pushbutton it should take the input from LineEdit1 and make some calculations and displayed in LineEdit2.
- Using signal and slot mechanism i connected the widgets in below manner in ui_LayoutDesign.h file
Code:
QObject::connect(PushButton,
SIGNAL(clicked
()), LayoutDesign,
SLOT(Convert
()));
QObject::connect(LineEdit1,
SIGNAL(activated
(int)), LayoutDesign,
SLOT(Convert
()));
QObject::connect(LineEdit2,
SIGNAL(activated
(int)), LayoutDesign,
SLOT(Convert
()));
The Convert() slot specified in the connect function is newly added slot(it means it is not predefined).
Here My question is where to define the Convert() slot in my code.:(
Re: problem with userdefined slot definition in QT4.4.3
I think it will be better if you declare userdefined function prototype in .h file & function in .cpp file and use SIGNAL and SLOT mechanism.
Re: problem with userdefined slot definition in QT4.4.3
Hi,
I am pretty newqt user but I think that your problem could be in the receiver object. You can try it without passing receiver name.
Re: problem with userdefined slot definition in QT4.4.3
hii
The meathod i know is :
1.In your .h(not ui.h) file declare:
private slots:
void Convert();
2. In your .cpp file add :
connect(PushButton, SIGNAL(clicked()), LayoutDesign, SLOT(Convert()));
Hope you understand
u Happ
Re: problem with userdefined slot definition in QT4.4.3
Thank u aj, now i got the solution with ur reply