diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm index f67a66a2d36..8472506d235 100644 --- a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm +++ b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm @@ -9,12 +9,15 @@ #include "qcocoawindow.h" #include "qcocoascreen.h" +#include #include #include #include QT_USE_NAMESPACE +Q_LOGGING_CATEGORY(lcAccessibilityTable, "qt.accessibility.table") + #if QT_CONFIG(accessibility) /** @@ -131,6 +134,12 @@ - (instancetype)initWithId:(QAccessible::Id)anId role:(NSAccessibilityRole)role auto *tableElement = [QMacAccessibilityElement elementWithInterface:table]; Q_ASSERT(tableElement); Q_ASSERT(tableElement->rows); + + qCDebug(lcAccessibilityTable) << "Creating cell representation for" + << m_rowIndex << m_columnIndex + << "in table with" + << tableElement->rows.count << "rows"; + Q_ASSERT(int(tableElement->rows.count) > m_rowIndex); auto *rowElement = tableElement->rows[m_rowIndex]; if (!rowElement->columns) { @@ -273,6 +282,8 @@ - (void)updateTableModel if (QAccessibleInterface *iface = self.qtInterface) { if (QAccessibleTableInterface *table = iface->tableInterface()) { Q_ASSERT(!self.isManagedByParent); + qCDebug(lcAccessibilityTable) << "Updating table representation with" + << table->rowCount() << table->columnCount(); rows = [self populateTableArray:rows role:NSAccessibilityRowRole count:table->rowCount()]; columns = [self populateTableArray:columns role:NSAccessibilityColumnRole count:table->columnCount()]; } diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index dd41863f47d..9b10ca7e35a 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -1096,6 +1096,17 @@ void QComboBoxPrivate::_q_rowsInserted(const QModelIndex &parent, int start, int // set current index if combo was previously empty and there is no placeholderText if (start == 0 && (end - start + 1) == q->count() && !currentIndex.isValid() && placeholderText.isEmpty()) { +#if QT_CONFIG(accessibility) + // This might have been called by the model emitting rowInserted(), at which + // point the view won't have updated the accessibility bridge yet about its new + // dimensions. Do it now so that the change of the selection matches the row + // indexes of the accessibility bridge's representation. + if (container && container->itemView()) { + QAccessibleTableModelChangeEvent event(container->itemView(), + QAccessibleTableModelChangeEvent::ModelReset); + QAccessible::updateAccessibility(&event); + } +#endif q->setCurrentIndex(0); // need to emit changed if model updated index "silently" } else if (currentIndex.row() != indexBeforeChange) {