Results 1 to 5 of 5

Thread: problem with userdefined slot definition in QT4.4.3

  1. #1

    Default problem with userdefined slot definition in QT4.4.3

    Hi,

    1. I created a project(LayoutDesign) in QT4.4.3,it created LayoutDesign.ui ,LayoutDesign.h,LayoutDesign.cpp and main.cpp file
    2. I opened the ui file using QTDesigner and i added 3 widgets(LineEdit1,Pushbutton,LineEdit2) on to it.
    3. my intention is when i click Pushbutton it should take the input from LineEdit1 and make some calculations and displayed in LineEdit2.
    4. Using signal and slot mechanism i connected the widgets in below manner in ui_LayoutDesign.h file

    Qt Code:
    1. QObject::connect(PushButton, SIGNAL(clicked()), LayoutDesign, SLOT(Convert()));
    2. QObject::connect(LineEdit1, SIGNAL(activated(int)), LayoutDesign, SLOT(Convert()));
    3. QObject::connect(LineEdit2, SIGNAL(activated(int)), LayoutDesign, SLOT(Convert()));
    To copy to clipboard, switch view to plain text mode 

    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.
    Last edited by jpn; 31st December 2008 at 08:12. Reason: missing [code] tags

  2. #2
    Join Date
    Sep 2008
    Posts
    84
    Thanks
    28
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default 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.

  3. #3
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default 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.

  4. #4
    Join Date
    Sep 2008
    Posts
    84
    Thanks
    28
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default 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

  5. #5

    Default Re: problem with userdefined slot definition in QT4.4.3

    Thank u aj, now i got the solution with ur reply

Similar Threads

  1. Problem When Creating my own Slot
    By Fatla in forum Qt Programming
    Replies: 12
    Last Post: 6th June 2008, 14:44

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.