CANpie FD
CAN programming interface environment - Version 3.08
Signals | Public Member Functions
QCanSocketDialog Class Reference

Detailed Description

The QCanSocketDialog class provides a dialog for connection to an existing QCanNetwork. The dialog creates a new QCanSocket and tries to connect after exec() is called. It is possible to setup the desired CAN channel by calling setChannel() in advance. Also the QCanServer host address can be configured by calling setHostAddress().

The following code snippet shows the usage of the QCanSocketDialog class.

QCanSocketDialog * pclDialogT;
pclDialogT = new QCanSocketDialog(this);
if (pclDialogT->exec() == QDialog::Accepted)
{
if (pclDialogT->channel() != eCAN_CHANNEL_NONE)
{
//------------------------------------------------
// get the selected CAN channel
//
uint8_t ubCanChannelT = pclDialogT->channel();
//------------------------------------------------
// if you don't want to use the socket, close it
// here
//
pclDialogT->socket()->disconnectNetwork();
}
}
delete (pclDialogT);

The status of the connection is displayed after the CAN details label.

QCanSocketDialog

Inherits QDialog.

Signals

void socketSelected (QCanSocket *pclSocketV)
 

Public Member Functions

 QCanSocketDialog (QWidget *pclParentV, Qt::WindowFlags f)
 
 QCanSocketDialog (QWidget *pclParentV=Q_NULLPTR, const QString &caption=QString())
 
CAN_Channel_e channel () const
 
int exec (void)
 
QHostAddress peerAddress () const
 
void setHostAddress (const QHostAddress clHostAddressV)
 
void setChannel (const CAN_Channel_e teChannelV)
 

Constructor & Destructor Documentation

◆ QCanSocketDialog() [1/2]

QCanSocketDialog::QCanSocketDialog ( QWidget *  pclParentV,
Qt::WindowFlags  f 
)
Parameters
[in]pclParentVPointer to QWidget parent class

Create a new CAN socket dialog.

◆ QCanSocketDialog() [2/2]

QCanSocketDialog::QCanSocketDialog ( QWidget *  pclParentV = Q_NULLPTR,
const QString &  caption = QString() 
)
Parameters
[in]pclParentVPointer to QWidget parent class

Create a new CAN socket dialog.

Member Function Documentation

◆ channel()

CAN_Channel_e QCanSocketDialog::channel ( ) const
Returns
CAN channel number

The function returns the selected CAN channel number. In case 'Cancel' has been pressed or the connection to the QCanServer failed the function will return QCan::eCAN_CHANNEL_NONE.

◆ exec()

int QCanSocketDialog::exec ( void  )
Returns
QDialog::DialogCode

Shows the dialog as a modal dialog, blocking until the user closes it. The function returns either QDialog::Accepted or QDialog::Rejected.

◆ peerAddress()

QHostAddress QCanSocketDialog::peerAddress ( ) const
Returns
Server host address
See also
setHostAddress()

Setup the QCanServer host address which should be displayed as default before the exec() method is called.

◆ setChannel()

void QCanSocketDialog::setChannel ( const CAN_Channel_e  teChannelV)
Parameters
[in]teChannelVCAN channel number

Setup the CAN channel number which should be displayed as default before the exec() method is called.

◆ setHostAddress()

void QCanSocketDialog::setHostAddress ( const QHostAddress  clHostAddressV)
Parameters
[in]clHostAddressVServer host address
See also
peerAddress()

Setup the QCanServer host address which should be displayed as default before the exec() method is called.

◆ socketSelected

void QCanSocketDialog::socketSelected ( QCanSocket pclSocketV)
signal
Parameters
[in]pclSocketVPointer to socket

This signal is emitted when the dialog window is closed using the OK button.

QCanSocketDialog::exec
int exec(void)
QCanSocketDialog::channel
CAN_Channel_e channel() const
QCanSocketDialog::QCanSocketDialog
QCanSocketDialog(QWidget *pclParentV, Qt::WindowFlags f)
QCanSocket::disconnectNetwork
void disconnectNetwork(void)
QCanSocketDialog
CAN socket dialog.
Definition: qcan_socket_dialog.hpp:86