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. How to share Serial port opened in Main Window class with Dialog box class
Forum Updated to NodeBB v4.3 + New Features

How to share Serial port opened in Main Window class with Dialog box class

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 3 Posters 857 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
    saurabh162
    wrote on last edited by
    #1

    Dear Developers,

    In my Qt project I have two C++ classes named "MainWindow" and "DialogBox"

    I used serial port class object of QT to open a serial port in MainWindow class and now I want to send and receive data from "DialogBox" class using same serial port opened in MainWindow class.

    Please tell me what is correct approach to share same serial port object between MainWindow and DialogBox Class.

    Kindly inform me if you need any other information from me.

    Thank and Regards

    Saurabh Jain

    jsulmJ 1 Reply Last reply
    0
    • S saurabh162

      Dear Developers,

      In my Qt project I have two C++ classes named "MainWindow" and "DialogBox"

      I used serial port class object of QT to open a serial port in MainWindow class and now I want to send and receive data from "DialogBox" class using same serial port opened in MainWindow class.

      Please tell me what is correct approach to share same serial port object between MainWindow and DialogBox Class.

      Kindly inform me if you need any other information from me.

      Thank and Regards

      Saurabh Jain

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by jsulm
      #2

      @saurabh162 You could simply pass the pointer to the QSerialPort instance to the constructor of your dialog class...
      Isn't this same question as here: https://forum.qt.io/topic/93183/how-to-share-serial-port-object-between-two-classes
      Why do you ask same question two times?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      aha_1980A 1 Reply Last reply
      2
      • jsulmJ jsulm

        @saurabh162 You could simply pass the pointer to the QSerialPort instance to the constructor of your dialog class...
        Isn't this same question as here: https://forum.qt.io/topic/93183/how-to-share-serial-port-object-between-two-classes
        Why do you ask same question two times?

        aha_1980A Offline
        aha_1980A Offline
        aha_1980
        Lifetime Qt Champion
        wrote on last edited by
        #3

        @jsulm is right, one question is enough.

        Closing this one, please continue at https://forum.qt.io/topic/93183/how-to-share-serial-port-object-between-two-classes

        Thanks

        Qt has to stay free or it will die.

        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