Results 1 to 7 of 7

Thread: How to use QSerialPort for double thread

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to use QSerialPort for double thread

    My guess is that the problem is your missing Q(Core/Ui)Application instance.
    So the main thread is not "adopted" as a QThread and thus lacks the necessary event dispatcher for socketnotifier's event handling.

    Cheers,
    _

  2. #2
    Join Date
    Nov 2015
    Posts
    3
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: How to use QSerialPort for double thread

    Quote Originally Posted by Vikram.Saralaya View Post
    The Qt documentation says:


    The serial port read in your case probably happens in a separate thread.. You need to make sure read and write happens in the same thread in which you open the port. Hope that helps..

    Regards
    Vikram
    But how to do it?
    I think that my program use only one thread.


    Added after 15 minutes:


    Quote Originally Posted by anda_skoa View Post
    My guess is that the problem is your missing Q(Core/Ui)Application instance.
    So the main thread is not "adopted" as a QThread and thus lacks the necessary event dispatcher for socketnotifier's event handling.

    Cheers,
    _
    Make a widgets project?
    Last edited by nistar; 18th November 2015 at 14:54.

  3. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to use QSerialPort for double thread

    Quote Originally Posted by nistar View Post
    Make a widgets project?
    If you don't have any Qt UI then you don't need a widgets project.
    But you need an instance of QCoreApplication (or on of its subclasses) and run its event loop (by calling its exec() function).

    Just try to start with an empty main() function.
    Then creating and configuring the QSerialPort instance.
    Then maybe trying to write a fixed command.

    When that works, add the original code instead of the test QSerialDevice code.

    Cheers,
    _

  4. #4
    Join Date
    May 2015
    Posts
    66
    Thanks
    10
    Thanked 17 Times in 17 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How to use QSerialPort for double thread

    Try replacing QT += serialport with QT += core serialport in the pro file

  5. #5
    Join Date
    Nov 2015
    Posts
    3
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: How to use QSerialPort for double thread

    Quote Originally Posted by anda_skoa View Post
    My guess is that the problem is your missing Q(Core/Ui)Application instance.
    So the main thread is not "adopted" as a QThread and thus lacks the necessary event dispatcher for socketnotifier's event handling.

    Cheers,
    _
    O, I do it.
    Only make a application project, and copy the code.

    Thanks

Similar Threads

  1. QserialPort
    By arturs in forum Newbie
    Replies: 0
    Last Post: 13th May 2015, 20:37
  2. Qt5 cmake and QSerialPort
    By Chris.Burner in forum Newbie
    Replies: 1
    Last Post: 21st April 2013, 16:13
  3. Program not finding an existing double in a QList<double>
    By aarelovich in forum Qt Programming
    Replies: 2
    Last Post: 9th May 2011, 20:59
  4. Replies: 2
    Last Post: 24th June 2009, 15:38

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.