Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Program hangs when i emit a global variable (Solved)

    Mobile and Embedded
    1
    3
    1089
    Loading More Posts
    • 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.
    • H
      houmingc last edited by

      A qt statement connect Slot and Signals together. Like to understand how variable qint8
      is pass from Signals functions to Slot functions.

      @
      extern qint8 myvalue; //in slots cpp
      connect(UdpReceived, SIGNAL(TriggerReceived(qint8)), this, SLOT(TriggerSlot(qint8))) //constructor

      signals:
      void TriggerReceived(qint8 myvalue); //declaration, in signals .h

      qint8 myvalue //global value
      emit TriggerReceived( myvalue); //definition, in signals .cpp

      Or =====
      public:
      qint8 myvalue; //signals .h

      @

      i understand moc(meta object compiler) connects them together but how is varaible pass?
      The reason is because i declare variable-myvalue as global instead as class public variable.
      The program hangs either i emits this global or public variable

      Please enlighten me.

      1 Reply Last reply Reply Quote 0
      • H
        houmingc last edited by

        Could pass variable through connecting two objects but could not pass variables using extern. Why ??

        @
        connect(UdpReceived, SIGNAL(TriggerReceived(qint8)), this, SLOT(TriggerSlot(qint8)))
        @

        I could not pass variables using extern

        @
        extern qint8 m_valuetopass

        connect(UdpReceived, SIGNAL(TriggerReceived()), this, SLOT(TriggerSlot()))
        @

        signal has no implementation, but "emit TriggerReceived( myvalue)" is not declaration, either.

        1 Reply Last reply Reply Quote 0
        • H
          houmingc last edited by

          Thanks, Initially i did not emit a signal with parameter by value. I use a global value to pass between 2 cpp files.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post