chore: do something make old qt happy

This commit is contained in:
x-tools-author 2025-07-26 18:30:20 +08:00
parent e08b0bc327
commit 621b6e1319

View File

@ -80,7 +80,11 @@ void BarCodeAssistant::onExportButtonClicked()
return;
}
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
QPixmap pixmap = *ui->labelImage->pixmap();
#else
QPixmap pixmap = ui->labelImage->pixmap(Qt::ReturnByValue);
#endif
if (!pixmap.save(fileName)) {
QMessageBox::warning(this, tr("Save Image"), tr("Failed to save image."));
}
@ -100,7 +104,7 @@ void BarCodeAssistant::onRefreshButtonClicked()
} else {
// If user typed something, try to find matching type
QString currentText = ui->comboBoxType->currentText();
for (const auto &item : m_allItems) {
for (const auto &item : std::as_const(m_allItems)) {
if (item.second.compare(currentText, Qt::CaseInsensitive) == 0) {
barcodeType = item.first;
break;
@ -253,7 +257,7 @@ void BarCodeAssistant::setupTypeComboBox()
// Create completer for auto-completion
QStringList itemNames;
for (const auto &item : m_allItems) {
for (const auto &item : std::as_const(m_allItems)) {
itemNames << item.second;
}
@ -274,7 +278,7 @@ void BarCodeAssistant::updateComboBoxItems(const QString &filter)
ui->comboBoxType->clear();
// Filter items based on the search text
for (const auto &item : m_allItems) {
for (const auto &item : std::as_const(m_allItems)) {
if (filter.isEmpty() || item.second.contains(filter, Qt::CaseInsensitive)) {
ui->comboBoxType->addItem(item.second, item.first);
}