This problem has been solved. Using following answer received on other forum for Qt.



You could use signal and slot instead of sharing the actual QSerial object.
http://doc.qt.io/qt-5/signalsandslots.html
So define new slots in Mainwindow that forms your interface the dialog would use.
Like
void SendCmd(QByteArray data);

and in dialog ,
define new signals for buttons to use
void SendCmd(QByteArray data); ( yes same name as the slot in main)

then hook up dialogs signals to mainwindows slot before u call exec() on dialog and
then u can use serialport from dialog.
by simply doing
emit SendCmd(xxxx)

in buttons click or where u need it.

Alternatively, just add a parameter to the Dialogs constructor and pass the
QSerialPort from mainwindow when you construct the Dialog.