在处理MVC时遇到一个问题如下: 使用TreeView作为视图,Delegate中的editor是一个QWidget,在产生QWidget时,对应View中原来的文本依然存在[造成和delegate控件中的文字有所重叠]。有没有什么办法能去掉view中的文本。哪位高手指点一下,谢谢~ 以下是createEditor中的代码: - QWidget* NewColor::createEditor(QWidget * parent, const QModelIndex & index)
- {
- Q_UNUSED(index);
- QtColorEditWidget *color_edit_widget = new QtColorEditWidget(parent);
- connect(color_edit_widget, SIGNAL(valueChanged(const QColor&)), this, SLOT(setValue(const QColor&)));
- return color_edit_widget;
- }
QtColorEditWidget 是定义的一个类[该类
继承自QWidget,方法省略了,列出了它的成员,该类的效果类似于QtDesigner中编辑
颜色属性的控件],定义如下:
class QtColorEditWidget : public QWidget {
Q_OBJECT
private:
QColor m_color;
QLabel *m_pixmapLabel;
QLabel *m_label;
QToolButton *m_button;
};