×

Discussion Board

Results 1 to 4 of 4

Thread: static slots

  1. #1
    Registered User
    Join Date
    Sep 2010
    Posts
    6

    Unhappy static slots

    Hi. how do i connect signal to static slot?

    something like this:

    class myStaticClass
    {
    static void method(obj o)
    {
    QtObject::connect(o, SIGNAL(sig()), myStaticClass, SLOT(slt()));
    }
    static void slt()
    {
    //my slot
    }
    }

  2. #2
    Nokia Developer Moderator
    Join Date
    Mar 2009
    Posts
    1,024

    Re: static slots

    Hi, first of all your class needs Q_OBJECT macro to work; Second thing, the Qt meta system won't work with your class because you have to initialize the object instance before to run static method(obj).

    BTW Why do you need such code? What's the purpose?

  3. #3
    Registered User
    Join Date
    Sep 2010
    Posts
    6

    Re: static slots

    Thanks for the info.
    My proces uses static classes for intermodule communication, that is why i need static slots and signals.

    Quote Originally Posted by gnuton View Post
    Hi, first of all your class needs Q_OBJECT macro to work; Second thing, the Qt meta system won't work with your class because you have to initialize the object instance before to run static method(obj).

    BTW Why do you need such code? What's the purpose?

  4. #4
    Nokia Developer Moderator
    Join Date
    Mar 2009
    Posts
    1,024

    Re: static slots

    Well, try to use them in the right way. If you have doubts, just ask

Similar Threads

  1. slots
    By suneethapuchakayala in forum [Archived] Beginning Qt
    Replies: 3
    Last Post: 2011-04-28, 13:29
  2. signals and slots
    By prathibha83 in forum Qt
    Replies: 3
    Last Post: 2010-06-21, 18:24
  3. Replies: 3
    Last Post: 2009-12-11, 02:36
  4. Replies: 10
    Last Post: 2008-08-19, 03:08

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •