I tested the application under Windows. There are no performance problems, but the CPU usage is higher. I think the animation (which I don't really need) is not worth it considering the higher CPU usage.
As already mentioned I'm also displaying QComboBoxes in another column. Currently I'm using openPersistentEditor() to display them. Now I've tried to display them by manual painting:
void ComboBoxItemDelegate
::paint(QPainter *painter,
const QStyleOptionViewItem &option,
const QModelIndex &index
) const//(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const {
comboBoxOption.rect = option.rect;
comboBoxOption.state = option.state;
comboBoxOption.
state |
= QStyle::State_Enabled;
comboBoxOption.
state |
= QStyle::State_On;
comboBoxOption.
subControls = QStyle::SC_All;
comboBoxOption.editable = false;
comboBoxOption.currentText = index.model()->data(index).toString();
}
void ComboBoxItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const//(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
QStyleOptionComboBox comboBoxOption;
comboBoxOption.rect = option.rect;
comboBoxOption.state = option.state;
comboBoxOption.state |= QStyle::State_Enabled;
comboBoxOption.state |= QStyle::State_On;
comboBoxOption.subControls = QStyle::SC_All;
comboBoxOption.editable = false;
comboBoxOption.currentText = index.model()->data(index).toString();
QApplication::style()->drawComplexControl(QStyle::CC_ComboBox, &comboBoxOption, painter);
QApplication::style()->drawControl(QStyle::CE_ComboBoxLabel, &comboBoxOption, painter);
}
To copy to clipboard, switch view to plain text mode
On Windows the code works, but on Linux (when using QGtkStyle) I'm just getting the ComboBoxLabel. Does anybody know why painting the combo box not works with QGtkStyle?
Bookmarks