[Qt-interest] Problem with QLineEdit in QTableWidget
Maximilien Renard
iixamaxii at gmail.com
Sun Apr 12 18:28:25 CEST 2009
Hi there,
I'm having some troubles with a little app I'm creating. I'm trying to
code a little script for this app which will allow me to edit, add,...
QSettings variables.
Therefore, I'm trying to display all the vars in a QTableWidget with
several other widgets. This is how it looks like :
_______________________________________________________________________________________
| |
| |
|
| QString(Key Name) | QPushButton(Edit Key Type) | QLineEdit(Value)
| QCheckBox(Remove) |
| |
| |
|
--------------------------------------------------------------------------------------------------------------------------
:-°
The 3rd cell's widget is not always a QLineEdit (depending on the Key
Type). It works fine with QDoubleSpinBox,... but not with QLineEdit.
My problem is : when I set the current value of the Key with
setText(), the text isn't displayed. When retrieving it with text()
it's OK but it is not shown. As soon as I type something into it, the
key value is replaced and the new text is displayed.
I couldn't figure out what I'm doing wrong and it's very annoying !
http://code.google.com/p/booksellermanager/source/browse/trunk/src/dialogconfig.cpp
here is the complete code and here is a little part of it :
} else if(m_SettingsList.at(i)->GetKeyType() == QVariant::String) {
m_KeyTypeWidgetsList.append(new QPushButton(tr("Change type (string)")));
QLineEdit * LineEdit = new QLineEdit;
LineEdit->setText(m_SettingsList.at(i)->GetKeyValue().toString());
qDebug() << LineEdit->text();
m_KeyValueWidgetsList.append(LineEdit);
connect(LineEdit, SIGNAL(textEdited(QString)), this, SLOT(ValueChanged()));
}
(....)
connect(m_KeyTypeWidgetsList.at(i), SIGNAL(clicked()), this,
SLOT(TypeChanged()));
m_RemoveKeyWidgetsList.append(new QCheckBox(tr("Remove")));
m_TableWidget->setItem(i, 0, new
QTableWidgetItem(m_SettingsList.at(i)->GetKeyName()));
m_TableWidget->setCellWidget(i, 1, m_KeyTypeWidgetsList.at(i));
m_TableWidget->setCellWidget(i, 2, m_KeyValueWidgetsList.at(i));
m_TableWidget->setCellWidget(i, 3, m_RemoveKeyWidgetsList.at(i));
I'd appreciate any help !
Many thanks,
Best regards,
Maximilien
P.S. If you're wondering why I'm not directly using the cell (it seems
possible) to enter text, that's just because I don't want to do that
:-°
More information about the Qt-interest-old
mailing list