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. Using QThread , Signal() , Slot() So GUI won't freeze
Forum Updated to NodeBB v4.3 + New Features

Using QThread , Signal() , Slot() So GUI won't freeze

Scheduled Pinned Locked Moved Unsolved General and Desktop
42 Posts 8 Posters 6.3k Views 4 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.
  • _ __d4ve__

    @jsulm

    Yes,

    signals:
        void update_gui(QString packetInfoQString);
    };
    

    The issue is here : pcap_loop got call back function named packet_handle - this function emit update_gui

    but the problem here that pcap_loop requires static function , while packet_handle can't be static function

    try to run the project that's very short code

    Pl45m4P Offline
    Pl45m4P Offline
    Pl45m4
    wrote on last edited by
    #41

    @__d4ve__ said in Using QThread , Signal() , Slot() So GUI won't freeze:

    signals:
    void update_gui(QString packetInfoQString);
    };

    Where is this signal defined?

    In the code snippet you've posted here, you have a function called
    (I dont know if this is still your current code...)

    void workerobject::packet_looper()
    { .... }
    

    so one can assume it's a part of your workerobject.cpp file.
    Above that code there is

    void packet_handler(u_char* user_data, const struct pcap_pkthdr* packet_header, const u_char* packet_data)
    {
        // .....
        emit update_gui(packetInfoQString);
    }
    

    Are you aware that packet_handler when written like that, is not a member of any class? It's defined as global function and there it probably wont recognize what update_gui is.
    The same applies, when trying to emit that signal from somewhere else other than where it was defined.


    If debugging is the process of removing software bugs, then programming must be the process of putting them in.

    ~E. W. Dijkstra

    SGaistS 1 Reply Last reply
    1
    • Pl45m4P Pl45m4

      @__d4ve__ said in Using QThread , Signal() , Slot() So GUI won't freeze:

      signals:
      void update_gui(QString packetInfoQString);
      };

      Where is this signal defined?

      In the code snippet you've posted here, you have a function called
      (I dont know if this is still your current code...)

      void workerobject::packet_looper()
      { .... }
      

      so one can assume it's a part of your workerobject.cpp file.
      Above that code there is

      void packet_handler(u_char* user_data, const struct pcap_pkthdr* packet_header, const u_char* packet_data)
      {
          // .....
          emit update_gui(packetInfoQString);
      }
      

      Are you aware that packet_handler when written like that, is not a member of any class? It's defined as global function and there it probably wont recognize what update_gui is.
      The same applies, when trying to emit that signal from somewhere else other than where it was defined.

      SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #42

      To add to my fellows, it's typically a good case for the use of invokeMethod.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      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