Project

General

Profile

Wt 4.9.2 WComboBox->setCurrentIndex does not work

Added by Cemal DEMİR 5 months ago

for ( int i = 0 ; i < m_outPutPowerModel->rowCount() ; i++ ) {
uint8_t m_watt = cpp17::any_cast<uint8_t>( m_outPutPowerModel->data( m_outPutPowerModel->index( i , 0 ) , Wt::ItemDataRole::User ));
qDebug() << __LINE__ << Q_FUNC_INFO << i << m_watt << periodicPack.outputPower;
if( periodicPack.outputPower == m_watt ) {
qDebug() << "SetCurrent Index" << i << periodicPack.outputPower << m_watt;
m_outputPowerComboBox->setCurrentIndex( i );
break;
}
}

console log:
SetCurrent Index 2 7 7

but combobox does not switch to index


Replies (3)

RE: Wt 4.9.2 WComboBox->setCurrentIndex does not work - Added by Cemal DEMİR 5 months ago

Cemal DEMİR wrote:

for ( int i = 0 ; i < m_outPutPowerModel->rowCount() ; i++ ) {
uint8_t m_watt = cpp17::any_cast<uint8_t>( m_outPutPowerModel->data( m_outPutPowerModel->index( i , 0 ) , Wt::ItemDataRole::User ));
qDebug() << __LINE__ << Q_FUNC_INFO << i << m_watt << periodicPack.outputPower;
if( periodicPack.outputPower == m_watt ) {
qDebug() << "SetCurrent Index" << i << periodicPack.outputPower << m_watt;
m_outputPowerComboBox->setCurrentIndex( i );
break;
}
}

console log:
SetCurrent Index 2 7 7

but combobox does not switch to index

when check combobox->currentIndex() log to console expected but not show. I dont understand

RE: Wt 4.9.2 WComboBox->setCurrentIndex does not work - Added by Mark Travis 5 months ago

You've got m_outputPowerComboBox->setModel(m_outPutPowerModel); in your code, correct?
as well as m_outputPowerComboBox->setModelColumn(which column of the model you want to display)

Are items showing up in your WComboBox, but you can't do anything with the index?

For what it's worth, I'm using it all over the place in 4.10.1 and it works fine.

RE: Wt 4.9.2 WComboBox->setCurrentIndex does not work - Added by Matthias Van Ceulebroeck 5 months ago

Hi Cemal,

your example is not really sufficient for me to be able to reproduce your issue. From a glance, I would suspect the Wt::ItemDataRole::User may be the culprit here, unless you of course added that to the model.

I would appreciate a minimal viable example, so I can examine this issue, and if necessary create a fix for it.

Best regards,
Matthias

    (1-3/3)