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. QThread
Forum Updated to NodeBB v4.3 + New Features

QThread

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 932 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.
  • S Offline
    S Offline
    sarahjohn
    wrote on last edited by
    #1

    Hi,
    I am trying to capture the screenshots of webpage in qtbrowser and sent it to a remote machine on every event occurance like mouse event from remote machine and keyboard event in host machine.So I need a thread to start which should start on every event occurance and sent to a remote machine over QTcpSocket.I tried building the program with fancy browser.I used to save the frame in an image file as

    @QImage image(frame->contentsSize(), QImage::Format_ARGB32_Premultiplied);
    image.fill(Qt::transparent);

    QPainter painter(&image);
    painter.setRenderHint(QPainter::Antialiasing, true);
    painter.setRenderHint(QPainter::TextAntialiasing, true);
    painter.setRenderHint(QPainter::SmoothPixmapTransform, true);
    frame->render(&painter);
    image.save(filename,"JPG")
    

    @

    I need to create a thread to do the above function and sent it over remote machine and wait for any other event to occur(keybord,mouse) ,if occured then process the event and again sent the changed screenshot to client.How can I start the thread in mainwindow.cpp to do the above function.I started the QTcpServer at beginning and when client connects i did QTcpSocket to read the events from remote and process the event and then start the thread.If any event from host machine occured also  I need to start the thread.How can I do this
    
    1 Reply Last reply
    0
    • D Offline
      D Offline
      daemon777
      wrote on last edited by
      #2

      I am not sure why you need a new thead for this. Qt is already event-based. What you would need is a slot which is connected to all the events you want to supervise and do your screenshot & sending-stuff there.

      But maybe I missed the point?

      1 Reply Last reply
      0
      • JeroentjehomeJ Offline
        JeroentjehomeJ Offline
        Jeroentjehome
        wrote on last edited by
        #3

        Hi,
        One big problem with a seperate thread is that it can not get or hold GUI elements! Only the main thread may control the GUI. So to utilize the sending thread you should use a signal/slot mechanism to give the data to the other thread.
        Within a custom TCPIP protocol package data you could issue a remote capture and send image command. The communication thread will call a slot to start the capture of the GUI element. When done the QImage should be transferred to the sending thread via signal/slot.
        Easy as that ;-)
        Maybe read about QtConcurrent for short threads and explenations about what Qt classes to chose for multithreading!

        Greetz, Jeroen

        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