Results 1 to 4 of 4

Thread: Signal-Slot, object instances

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2006
    Posts
    91
    Thanks
    4
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Signal-Slot, object instances

    I am using a designer..and I was curious whether one could make a signal slot connection without making a instance of a object but declaring a object..

    MyObj *obj;
    connect(obj,SIGNAL(),this,SLOT());

    obj=new MyObj();


    just curious whether this would be valid
    Humans make mistake because there is really NO patch for HUMAN STUPIDITY

  2. #2
    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: Signal-Slot, object instances

    What actually do you mean?
    In designer genearated files i never see something like that
    a life without programming is like an empty bottle

  3. #3
    Join Date
    Feb 2006
    Posts
    91
    Thanks
    4
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Signal-Slot, object instances

    Well in designer you don't actually have the
    MyObj *obj;

    it is written at the public member Object explorer.
    Now, generally before using the object we need to create a instance for it..I am asking can we use the object without creating its instance in a signal slot connection ..and what may its consequences be.
    Humans make mistake because there is really NO patch for HUMAN STUPIDITY

  4. #4
    Join Date
    Jan 2006
    Posts
    22
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Signal-Slot, object instances

    Qt Code:
    1. MyObj *obj;
    2. connect(obj,SIGNAL(),this,SLOT());
    To copy to clipboard, switch view to plain text mode 
    This will crash.

    You are passing an uninitialized pointer to connect(). If you're lucky obj is initialized with 0 and connect() checks for 0-pointers, but generally accessing an uninitialized object is simply shooting yourself in the foot.

Similar Threads

  1. pthread instead QThread
    By brevleq in forum Qt Programming
    Replies: 8
    Last Post: 23rd December 2008, 08:16
  2. Connection of custon signals/slots
    By brevleq in forum Qt Programming
    Replies: 2
    Last Post: 23rd December 2008, 08:04
  3. retrieving signal name in a slot
    By Baschterl in forum Qt Programming
    Replies: 2
    Last Post: 10th November 2008, 21:44
  4. Signal to specific object slot
    By bunjee in forum Qt Programming
    Replies: 2
    Last Post: 27th December 2007, 16:51
  5. Replies: 2
    Last Post: 17th May 2006, 22:01

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.