Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Program hangs when i emit a global variable (Solved)
QtWS25 Last Chance

Program hangs when i emit a global variable (Solved)

Scheduled Pinned Locked Moved Mobile and Embedded
3 Posts 1 Posters 1.3k Views
  • 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 Offline
    H Offline
    houmingc
    wrote on last edited by
    #1

    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
    0
    • H Offline
      H Offline
      houmingc
      wrote on last edited by
      #2

      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
      0
      • H Offline
        H Offline
        houmingc
        wrote on last edited by
        #3

        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
        0

        • Login

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