Below is an example of my code structure.
I tried at first putting a 10 ms delay in the timer, but my device can generate 1000s of data packets each second. So, I just grab the latest one and display when I do a get.
CommGUI
::CommGUI(Comm
*drwg,
QWidget *parent
){
ui.setupUi(this);
refreshTimer->start(0);
QObject::connect(refreshTimer,
SIGNAL(timeout
()),
this,
SLOT(UpdateGUI
()));
}
CommGUI::CommGUI(Comm *drwg, QWidget *parent)
: QMainWindow(parent)
{
ui.setupUi(this);
QTimer *refreshTimer = new QTimer(this);
refreshTimer->start(0);
QObject::connect(refreshTimer, SIGNAL(timeout()), this, SLOT(UpdateGUI()));
}
To copy to clipboard, switch view to plain text mode
void CommGUI::UpdateGUI()
{
// Get Message from device
// put data into map
// this runs fast and is running in a separate thread
// example spinbox update
// 80 of these
ui.spinbox->setValue(map.value);
return;
}
void CommGUI::UpdateGUI()
{
// Get Message from device
// put data into map
// this runs fast and is running in a separate thread
// example spinbox update
// 80 of these
ui.spinbox->setValue(map.value);
return;
}
To copy to clipboard, switch view to plain text mode
Bookmarks