typedef struct
{
unsigned int m_Btr0Btr1;
} baudrate_t;
...
const baudrate_t available_bauds[]={ {"1 MBaud/s",0x014},
{"800 kBaud/s",0x0016},
{"500 kBaud/s",0x001C},
{"250 kBaud/s",0x011C},
{"125 kBaud/s",0x031C},
{"100 kBaud/s",0x432F},
{"95 kBaud/s",0xC34E},
{"83 kBaud/s",0x852B},
{"50 kBaud/s",0x472F},
{"47 kBaud/s",0x1414},
{"33 kBaud/s",0x8B2F},
{"20 kBaud/s",0x532F},
{"10 kBaud/s",0x672F},
{"5 kBaud/s",0x7F7F},
};
...
for (int i = 0; i<( sizeof(available_bauds) / sizeof(available_bauds[0]) ); ++i)
{
QString Label
= available_bauds
[i
].
m_displayName;
unsigned int BTR0BTR1 = available_bauds[i].m_Btr0Btr1;
ui
->cB_baudrate
->addItem
(Label,
QVariant(BTR0BTR1
));
}
/*DEBUG Code*/
qDebug() << ui->cB_baudrate->itemText(2);
QVariant check_data
= ui
->cB_baudrate
->itemData
(2,Qt
::UserRole);
bool ok = false;
unsigned int check_btr0btr1 = check_data.toUInt(&ok);
if (ok)
{
qDebug() << check_btr0btr1;
}
/*END DEBUG CODE*/
typedef struct
{
QString m_displayName;
unsigned int m_Btr0Btr1;
} baudrate_t;
...
const baudrate_t available_bauds[]={ {"1 MBaud/s",0x014},
{"800 kBaud/s",0x0016},
{"500 kBaud/s",0x001C},
{"250 kBaud/s",0x011C},
{"125 kBaud/s",0x031C},
{"100 kBaud/s",0x432F},
{"95 kBaud/s",0xC34E},
{"83 kBaud/s",0x852B},
{"50 kBaud/s",0x472F},
{"47 kBaud/s",0x1414},
{"33 kBaud/s",0x8B2F},
{"20 kBaud/s",0x532F},
{"10 kBaud/s",0x672F},
{"5 kBaud/s",0x7F7F},
};
...
for (int i = 0; i<( sizeof(available_bauds) / sizeof(available_bauds[0]) ); ++i)
{
QString Label = available_bauds[i].m_displayName;
unsigned int BTR0BTR1 = available_bauds[i].m_Btr0Btr1;
ui->cB_baudrate->addItem(Label,QVariant(BTR0BTR1));
}
/*DEBUG Code*/
qDebug() << ui->cB_baudrate->itemText(2);
QVariant check_data = ui->cB_baudrate->itemData(2,Qt::UserRole);
bool ok = false;
unsigned int check_btr0btr1 = check_data.toUInt(&ok);
if (ok)
{
qDebug() << check_btr0btr1;
}
/*END DEBUG CODE*/
To copy to clipboard, switch view to plain text mode
Bookmarks