Skip to content
  • 0 Votes
    3 Posts
    1k Views
    kshegunovK
    @JKSH I would give MyMessageHandler only 1 slot. Inside this slot, query the QMpiMessage to discover its subclass, and then call the appropriate function to process it. I was more interested in the meta-object magic I have to perform, to call the appropriate function, but I think I'd found how to do it. That's a bit like asking "How to connect to QSlider::valueChanged(int), and invoke different slots depending on whether the value is odd or even?" The answer is: You can't. Slots are invoked based on the sender object ID and the signal ID, but not the signal parameter values. In your description, you only have 1 signal. All slots connected to that signal will be invoked each time the signal is emitted. Emitting a signal that carries a different subclass of QMpiMessage is just like emitting a signal that carries a different number. If you want to invoke different slots, then you need to emit different signals. Fair enough. I admit I've used "connect" and "slot" a bit frivolously, so I probably need to put more effort in writing clearer questions. In any case, your comment I believe pointed me in the right direction, so I thank you for that! Kind regards.
  • Meta-type id of an object

    Solved General and Desktop qmetaobject qmetatype
    13
    0 Votes
    13 Posts
    10k Views
    kshegunovK
    Well, just letting you know that Chris' suggestion seems the most painless way to do the thing I need, so I'm going with it. Thanks all!
  • 0 Votes
    4 Posts
    3k Views
    Guy GizmoG
    @mrjj I believe you are correct. I found out that the problem is my use of Q_DECLARE_OPAQUE_POINTER. It apparently prevents the meta type from registering as being derived from a QObject, which makes sense since at that point there's no way for Qt to know what the class is. I refactored my code so that MyClass_p is no longer private or forward declared, and it fixed the issue.
  • Converting Enums to Strings for QPrinter

    Unsolved General and Desktop qprinter enum qt4 qmetaobject
    13
    0 Votes
    13 Posts
    6k Views
    D
    Let me tone down this discussion by saying that the original reason for my question has disappeared. I misunderstood how QPrinter worked. I thought I would need the string versions of the QPrintDialog enums to pass on to lp. Turns out QPrinter does what I need to do automatically and I don't need to call lp. Thanks for the lively discussion though.
  • 0 Votes
    12 Posts
    5k Views
    W
    @mrjj Thanks)
  • Proper usage of QMetaObject::invokeMethod

    Unsolved Mobile and Embedded qthread qmetaobject
    2
    0 Votes
    2 Posts
    3k Views
    JKSHJ
    @Usman93 said: I read that QMetaObject::invokeMethod shall be used to invoke methods of an object which is affined to a different thread from the calling thread. Correct. Lets suppose we have two threads a pthread and a qthread. Is it allowed to call QMetaObject::invokeMethod from pthread to invoke a method of a worker object in Qthread. Yes, it's allowed. Could you please help me understand this. See http://doc.qt.io/qt-5/qmetaobject.html#invokeMethod for some example code.
  • QMetaObject questions

    General and Desktop qmetaobject
    6
    0 Votes
    6 Posts
    2k Views
    G
    Hi guys Thanks for your replies It turns out the the derived class did not have the Q_OBJECT macro All working now Thanks