MarkoSan
17th June 2008, 23:23
Hi to all!
I've created combo box on some widget with:
m_pDatabaseSelector=new QComboBox(this); // creates new combo box
Q_CHECK_PTR(m_pDatabaseSelector); // checks creationand then fill it with:
m_pDatabaseSelector->addItem(strdbType); // adds db type to combo box
m_pDatabaseSelector->addItem("ODBC"); // adds db type to combo box
m_pDatabaseSelector->addItem("SQLite"); // adds db type to combo boxCombo box is shown and all item are in it as should be. Now, I've connected data selection signal with my slot:
connect(m_pDatabaseSelector,
SIGNAL(currentIndexChanged(int)),
this,
SLOT(itemChanged(int))); // signal connectorand here the code for itemChanged(int):
void CDatabaseSettingsPage::itemChanged(int iSelectedIndex)
{
qDebug() << "iSelectedIndex:" << iSelectedIndex;
qDebug() << "m_pDatabaseSelector->itemData(iSelectedIndex).toString():" << m_pDatabaseSelector->itemData(iSelectedIndex).toString();
m_pAppSettings->updateRecord(databaseSettingKey,
strDatabaseTypeKey,
m_pDatabaseSelector->itemData(iSelectedIndex).toString());
}Well, itemData() returns empty string, iSelectedIndex is correclty setup. Why??
I've created combo box on some widget with:
m_pDatabaseSelector=new QComboBox(this); // creates new combo box
Q_CHECK_PTR(m_pDatabaseSelector); // checks creationand then fill it with:
m_pDatabaseSelector->addItem(strdbType); // adds db type to combo box
m_pDatabaseSelector->addItem("ODBC"); // adds db type to combo box
m_pDatabaseSelector->addItem("SQLite"); // adds db type to combo boxCombo box is shown and all item are in it as should be. Now, I've connected data selection signal with my slot:
connect(m_pDatabaseSelector,
SIGNAL(currentIndexChanged(int)),
this,
SLOT(itemChanged(int))); // signal connectorand here the code for itemChanged(int):
void CDatabaseSettingsPage::itemChanged(int iSelectedIndex)
{
qDebug() << "iSelectedIndex:" << iSelectedIndex;
qDebug() << "m_pDatabaseSelector->itemData(iSelectedIndex).toString():" << m_pDatabaseSelector->itemData(iSelectedIndex).toString();
m_pAppSettings->updateRecord(databaseSettingKey,
strDatabaseTypeKey,
m_pDatabaseSelector->itemData(iSelectedIndex).toString());
}Well, itemData() returns empty string, iSelectedIndex is correclty setup. Why??