Results 1 to 8 of 8

Thread: Really New to QT and finding problem in very basics

  1. #1
    Join Date
    Feb 2006
    Location
    New Delhi,India
    Posts
    226
    Thanks
    14
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Unhappy 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

  2. #2
    Join Date
    Feb 2006
    Location
    New Delhi,India
    Posts
    226
    Thanks
    14
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default 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
    Attached Files Attached Files

  3. #3
    Join Date
    Feb 2006
    Location
    Enschede, NL, EU
    Posts
    19
    Thanks
    1
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default 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

  4. #4
    Join Date
    Jan 2006
    Location
    Ukraine,Lviv
    Posts
    454
    Thanks
    9
    Thanked 27 Times in 27 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: Really New to QT and finding problem in very basics

    In action.cpp replace your connect on next
    Qt Code:
    1. connect(mw->pushButton, SIGNAL(clicked()), SLOT(actionSlot()));
    To copy to clipboard, switch view to plain text mode 
    a life without programming is like an empty bottle

  5. #5
    Join Date
    Feb 2006
    Location
    New Delhi,India
    Posts
    226
    Thanks
    14
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Really New to QT and finding problem in very basics

    Quote Originally Posted by zlatko
    In action.cpp replace your connect on next
    Qt Code:
    1. connect(mw->pushButton, SIGNAL(clicked()), SLOT(actionSlot()));
    To copy to clipboard, switch view to plain text mode 

    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

  6. #6
    Join Date
    Feb 2006
    Location
    New Delhi,India
    Posts
    226
    Thanks
    14
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default 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

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

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

  8. #8
    Join Date
    Feb 2006
    Location
    New Delhi,India
    Posts
    226
    Thanks
    14
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default 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

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.