Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. new SIGNAL / SLOT syntax
Forum Updated to NodeBB v4.3 + New Features

new SIGNAL / SLOT syntax

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 620 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    RahibeMeryem
    wrote on last edited by
    #1

    Hi,

    in the old way we can write:

        connect(worker , SIGNAL(_bigChip_changed(QImage)) ,this , SLOT(bigChip_update(QImage)));
    
    

    I could find the syntax for new notation for "this":

       connect(worker , &Worker::_bigChip_changed , this , ??::bigChip_update);
    
    

    How can say

    ,this , SLOT(bigChip_update(QImage)))
    

    in new notation

    Thanks..

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by VRonin
      #2

      Use the type of this. See http://wiki.qt.io/New_Signal_Slot_Syntax

      A real example:

      class MyObject : public QObject{
      Q_OBJECT
      Q_DISABLE_COPY(MyObject)
      public:
      explicit MyObject(QObject* parent=Q_NULLPTR)
      :QObject(parent)
      ,m_timer(new QTimer(this))
      {
      connect(m_timer,&QTimer::timeOut,this,&MyObject::timerTimeOut);
      m_timer->start(1000);
      }
      private Q_SLOTS:
      void timerTimeOut(){qDebug("Timeout!");}
      private:
      QTimer* m_timer;
      };
      

      It you like hurting yourself, you could use

      connect(worker , &Worker::_bigChip_changed , this , &std::remove_const<std::remove_pointer<decltype(this)>::type>::type::bigChip_update);
      

      but I see no scenario ever to use such a monstrosity

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      1 Reply Last reply
      7
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by mrjj
        #3

        alt text
        Hehe VRonin, thats cool.
        Im not sure if it should come with warning, dont do this at home ;)

        So that basically strips the type info or what does it really do ?

        1 Reply Last reply
        1

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved