mirror of
https://github.com/qt/qtmqtt.git
synced 2026-10-25 16:16:26 +00:00
Add username and password edits
The example was missing that so far. Change-Id: I312dc4e67cb801313bb4811ceced4b78f985e9ab Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
This commit is contained in:
parent
b914736b14
commit
4a8f8f99c8
@ -89,6 +89,8 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
|
||||
connect(ui->lineEditHost, &QLineEdit::textChanged, m_client, &QMqttClient::setHostname);
|
||||
connect(ui->spinBoxPort, QOverload<int>::of(&QSpinBox::valueChanged), this, &MainWindow::setClientPort);
|
||||
connect(ui->lineEditUser, &QLineEdit::textChanged, m_client, &QMqttClient::setUsername);
|
||||
connect(ui->lineEditPassword, &QLineEdit::textChanged, m_client, &QMqttClient::setPassword);
|
||||
updateLogStateChange();
|
||||
}
|
||||
|
||||
@ -103,11 +105,15 @@ void MainWindow::on_buttonConnect_clicked()
|
||||
if (m_client->state() == QMqttClient::Disconnected) {
|
||||
ui->lineEditHost->setEnabled(false);
|
||||
ui->spinBoxPort->setEnabled(false);
|
||||
ui->lineEditUser->setEnabled(false);
|
||||
ui->lineEditPassword->setEnabled(false);
|
||||
ui->buttonConnect->setText(tr("Disconnect"));
|
||||
m_client->connectToHost();
|
||||
} else {
|
||||
ui->lineEditHost->setEnabled(true);
|
||||
ui->spinBoxPort->setEnabled(true);
|
||||
ui->lineEditUser->setEnabled(true);
|
||||
ui->lineEditPassword->setEnabled(true);
|
||||
ui->buttonConnect->setText(tr("Connect"));
|
||||
m_client->disconnectFromHost();
|
||||
}
|
||||
@ -131,6 +137,8 @@ void MainWindow::brokerDisconnected()
|
||||
{
|
||||
ui->lineEditHost->setEnabled(true);
|
||||
ui->spinBoxPort->setEnabled(true);
|
||||
ui->lineEditUser->setEnabled(true);
|
||||
ui->lineEditPassword->setEnabled(true);
|
||||
ui->buttonConnect->setText(tr("Connect"));
|
||||
}
|
||||
|
||||
|
||||
@ -23,13 +23,6 @@
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Host:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="lineEditHost">
|
||||
<property name="text">
|
||||
@ -37,6 +30,27 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="text">
|
||||
<string>Username:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QPushButton" name="buttonPing">
|
||||
<property name="text">
|
||||
<string>Ping</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Host:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
@ -61,10 +75,20 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QPushButton" name="buttonPing">
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_9">
|
||||
<property name="text">
|
||||
<string>Ping</string>
|
||||
<string>Password:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="lineEditUser"/>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="lineEditPassword">
|
||||
<property name="echoMode">
|
||||
<enum>QLineEdit::Password</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -227,7 +251,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1024</width>
|
||||
<height>21</height>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuFile">
|
||||
|
||||
Loading…
Reference in New Issue
Block a user