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. Resizing window blocks serialPort bot not the timer
Qt 6.11 is out! See what's new in the release blog

Resizing window blocks serialPort bot not the timer

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 1.9k 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.
  • M Offline
    M Offline
    mactro
    wrote on last edited by
    #1

    Hi,

    I'm developing an application to communicate with a robot via Bluetooth. Everything works fine, but when I resize or move an application window, slot connected to readyRead() is not being called. That would not be a terrible problem, but I also have a method to constantly monitoring the connection. When no data are read in certain period it assumes that the connection was lost, pops up a warning and closes the serial port. The method is fired by the timer timeout, which occurs even if I move a window, causing app to close the connection (because no data are read meanwhile).

    I do not use multihreading, relying only on signals and slots. How can I cause both methods to be executed during GUI operations, or both to be halted?

    @ //method fired by the timer
    void BoardConnection::pingBoard()
    {
    if(connectionAlive) {
    connection.write("^^\n");
    } else {
    disconnect();
    emit connectionLost();

    }
    connectionAlive = false;
    

    }

    // method connected to readyRead() slot
    void BoardConnection::readData()
    {
    connectionAlive = true;
    QByteArray data = connection.readAll();
    // process stuff
    }
    @

    1 Reply Last reply
    0
    • R Offline
      R Offline
      Rondog
      wrote on last edited by
      #2

      I have noticed some odd things with QSerialPort myself. It seems to be always related to the event loop in one way or another.

      I have a suggestion for a work around (not a solution). You can detect when your window is changing size or moving (override associated events) and when this is happening you can ignore your timer to shut down the serial port.

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mactro
        wrote on last edited by
        #3

        That's exactly what I am doing right now. But , as you said, it's just a workaround, not a solution. There is also a risk, that I will overlook some event (for example I have just found out, that not only main window resize or move hangs QSerialPort, but also dragging of default window status bar).

        1 Reply Last reply
        0
        • K Offline
          K Offline
          kuzulis
          Qt Champions 2020
          wrote on last edited by
          #4

          Hi.

          This fixed in future Qt 5.5 (but never will be fixed when uses Qt 4.x): https://bugreports.qt.io/browse/QTBUG-34946

          So, just use the QSerialPort in another thread (by using the moveToThread() method) or to wait up to Qt5.5 released.

          1 Reply Last reply
          1
          • M Offline
            M Offline
            mactro
            wrote on last edited by
            #5

            I was hoping to avoid multithreading somehow. Well, thanks for help anyway!

            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