Results 1 to 7 of 7

Thread: Create signal/slots in runtime ?

  1. #1
    Join Date
    Oct 2013
    Posts
    8
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Create signal/slots in runtime ?

    Hi,

    It's possible to create/generate signals and slots in runtime (not compile time) ?

    Regards,
    Thanks

  2. #2
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Create signal/slots in runtime ?

    What does it mean "create/generate signals and slots in runtime" ?

  3. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Create signal/slots in runtime ?

    Don't think so, but maybe we are not thinking about the same thing.
    What is it that you are trying to achieve?

    Cheers,
    _

  4. #4
    Join Date
    Oct 2013
    Posts
    8
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Create signal/slots in runtime ?

    Well

    Example I have an empty grilayout and receive a file to build ui by code.
    So I create an new QCombobox() and set values.
    Next I want to define a signal ex, changeCurrentIndex() and then generate a slot() dynamically, slot1(), slot2(), ...slotn()
    Can I generate a callback slot for that ?

    Cheers

  5. #5
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Create signal/slots in runtime ?

    You could have one slot and identify the sender using QObject::sender(), or have a dedicated receiver object for each row.

    Cheers,
    _

  6. #6
    Join Date
    Oct 2013
    Posts
    8
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Create signal/slots in runtime ?

    But I have previous in compile time define *.cpp code for that slot ?

    Thanks

  7. #7
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Create signal/slots in runtime ?

    The actions performed by a slot, which is just another class function not some magical entity, have to be compiled into a code unit somewhere. You cannot do that at runtime for C++. You can, of course, connect existing signals and slots at runtime. If the range of behaviours to be performed by the slotn() functions is known then you can pre-build them and connect at runtime if they are needed.

    Beyond that, it sounds like you want some sort of plugin that can provide a widget and associated processing logic. Qt has a plugin mechanism you can use.

Similar Threads

  1. Replies: 0
    Last Post: 28th October 2014, 17:16
  2. Create QMainWindow in runtime
    By qt_developer in forum Newbie
    Replies: 2
    Last Post: 25th June 2012, 19:22
  3. How do I create an Object at runtime?
    By Cayan in forum Newbie
    Replies: 2
    Last Post: 28th June 2010, 07:01
  4. create multiple buttons with signal and slots
    By mohanakrishnan in forum Qt Programming
    Replies: 8
    Last Post: 14th November 2009, 12:03
  5. add signal/slots at runtime?
    By oc2k1 in forum Qt Programming
    Replies: 10
    Last Post: 15th June 2009, 19:52

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.