2017-10-17 19:58:52 +08:00
|
|
|
#include "mainwindow.h"
|
|
|
|
#include "ui_mainwindow.h"
|
2017-11-23 19:12:48 +08:00
|
|
|
#include <qqtbluetoothmanager.h>
|
|
|
|
#include <qqtcore.h>
|
|
|
|
QQtBluetoothManager* manager = NULL;
|
2017-10-17 19:58:52 +08:00
|
|
|
|
2017-11-23 19:12:48 +08:00
|
|
|
MainWindow::MainWindow ( QWidget* parent ) :
|
|
|
|
QMainWindow ( parent ),
|
|
|
|
ui ( new Ui::MainWindow )
|
2017-10-17 19:58:52 +08:00
|
|
|
{
|
2017-11-23 19:12:48 +08:00
|
|
|
ui->setupUi ( this );
|
|
|
|
// bluetooth example
|
|
|
|
manager = QQtBluetoothManager::Instance ( this );
|
|
|
|
connect ( manager, SIGNAL ( addDevice ( QBluetoothDeviceInfo ) ), this, SLOT ( addDevice ( QBluetoothDeviceInfo ) ) );
|
|
|
|
connect ( manager, SIGNAL ( addService ( QBluetoothServiceInfo ) ), this,
|
|
|
|
SLOT ( addService ( QBluetoothServiceInfo ) ) );
|
|
|
|
ui->lw0->addItem ( manager->address().toString() );
|
2017-10-17 19:58:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
MainWindow::~MainWindow()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
2017-11-23 19:12:48 +08:00
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_btnRefresh_clicked()
|
|
|
|
{
|
|
|
|
ui->lw1->clear();
|
|
|
|
manager->refresh();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::addDevice ( QBluetoothDeviceInfo s )
|
|
|
|
{
|
|
|
|
ui->lw1->addItem ( s.address().toString() );
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::addService ( QBluetoothServiceInfo s )
|
|
|
|
{
|
|
|
|
pline() << s.serviceClassUuids();
|
|
|
|
}
|