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.
if (pclDialogT->
exec() == QDialog::Accepted)
{
if (pclDialogT->
channel() != eCAN_CHANNEL_NONE)
{
uint8_t ubCanChannelT = pclDialogT->
channel();
}
}
delete (pclDialogT);
CAN socket dialog.
Definition qcan_socket_dialog.hpp:87
QCan::CAN_Channel_e channel() const
QCanSocketDialog(QWidget *pclParentV, Qt::WindowFlags f)
void disconnectNetwork(void)
The status of the connection is displayed after the CAN details label.
QCanSocketDialog
#include <qcan_socket_dialog.hpp>
Inherits QDialog.
◆ QCanSocketDialog() [1/2]
| QCanSocketDialog::QCanSocketDialog |
( |
QWidget * | pclParentV, |
|
|
Qt::WindowFlags | f ) |
- Parameters
-
| [in] | pclParentV | Pointer to QWidget parent class |
Create a new CAN socket dialog.
◆ QCanSocketDialog() [2/2]
| QCanSocketDialog::QCanSocketDialog |
( |
QWidget * | pclParentV = nullptr, |
|
|
const QString & | caption = QString() ) |
- Parameters
-
| [in] | pclParentV | Pointer to QWidget parent class |
Create a new CAN socket dialog.
◆ channel()
- 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 | | ) |
|
|
override |
- 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 |
◆ setChannel()
- Parameters
-
| [in] | teChannelV | CAN 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] | clHostAddressV | Server 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] | pclSocketV | Pointer to socket |
This signal is emitted when the dialog window is closed using the OK button.