Results 1 to 14 of 14

Thread: Beginner problem with connect

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #6
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 453 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Beginner problem with connect

    Looks like you still have to figure out the basic object creation and scope work (it's C++ stuff)

    Qt Code:
    1. //program.cpp
    2. wnd1 w1; //this will create object on stack and will be destroyed as soon as function returns
    3. w1.Initialize(); //this is ok
    To copy to clipboard, switch view to plain text mode 


    Qt Code:
    1. //window1.cpp
    2. program oProg; //this not good, you are creating a global QMainWindow, that means you are trying to create a widget even before QApplication is created
    3.  
    4. void wnd1::Initialize() {
    5. QPushButton *b = oProg.centralWidget()->findChild<QPushButton *>("button1"); // you are not supposed to get the member widgets of other class this way, it will work but will end up in problems later
    6. wnd1 w1; //this will create object on stack and will be destroyed as soon as function returns
    7. w1.connect(b, SIGNAL(clicked()), SLOT(test())); //there is no such version of connect function, hence the error, and moreover it does not make sense to connect a object which will be deleted before this function returns. So even if you were able to get the correct version of the function, your slot will never get called, as the object itself is destroyed before this function returns
    8. }
    To copy to clipboard, switch view to plain text mode 

    Please try, as I suggested in my earlier post

  2. The following user says thank you to Santosh Reddy for this useful post:

    lucastonon (14th July 2011)

Similar Threads

  1. Problem with connect
    By eekhoorn12 in forum Newbie
    Replies: 3
    Last Post: 21st December 2010, 20:48
  2. connect() problem
    By harmodrew in forum Newbie
    Replies: 14
    Last Post: 5th August 2010, 17:45
  3. Connect Problem
    By nrabara in forum Newbie
    Replies: 3
    Last Post: 4th May 2009, 12:19
  4. Problem with connect()
    By mrnor3 in forum Qt Programming
    Replies: 3
    Last Post: 23rd July 2008, 14:05
  5. Qfiledialog Problem - (Beginner)
    By kingslee in forum Qt Tools
    Replies: 3
    Last Post: 11th October 2006, 23:00

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.