Results 1 to 7 of 7

Thread: QSerialPort closed when access from another class

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,328
    Thanks
    317
    Thanked 871 Times in 858 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QSerialPort closed when access from another class

    If the original code fragment posted is part of the real code, then the line "MainWindow m;" is creating a new second instance of MainWindow on the stack and is trying to use the QSerialPort that was previously created and opened in the first MainWindow instance.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  2. #2
    Join Date
    Feb 2016
    Location
    S. Stefano di Sessanio
    Posts
    11
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: QSerialPort closed when access from another class

    Quote Originally Posted by d_stranz View Post
    If the original code fragment posted is part of the real code, then the line "MainWindow m;" is creating a new second instance of MainWindow on the stack and is trying to use the QSerialPort that was previously created and opened in the first MainWindow instance.
    I see.. so which should be the best way to call a method/function defined in another class without calling a second instance of that class (like I did before)?
    Thank you!

  3. #3
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,540
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QSerialPort closed when access from another class

    You can pass the pointer of a QSerialPort object or use the signals and slots mechanism.

Similar Threads

  1. Replies: 1
    Last Post: 16th May 2017, 12:48
  2. Replies: 4
    Last Post: 12th November 2015, 13:00
  3. Replies: 4
    Last Post: 2nd April 2013, 09:13
  4. Replies: 4
    Last Post: 29th May 2010, 12:56
  5. Replies: 5
    Last Post: 14th July 2006, 22:42

Tags for this Thread

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.