网上没有找到可行的解决方法
你可以试着用treeView写个自己的tree控件
如果不想 看分割线以下
------------------------------------------------------------------
用QHeaderView替代
QHeaderView *head = treeWidget->header();
QLabel *label = new QMyLabel("MyTree");
QHBoxLayout *lay = new QHBoxLayout;
lay->setMargin(0);
lay->addWidget(label);
head->setLayout(lay);
自定义类:
class QMyLabel : public QLabel
{
public:
QMyLabel(const QString & text , QWidget * parent = 0);
~QMyLabel();
protected:
void paintEvent(QPaintEvent * event);
};
QMyLabel::QMyLabel(const QString & text , QWidget * parent) : QLabel(text , parent)
{
}
QMyLabel::~QMyLabel()
{
}
void QMyLabel::paintEvent(QPaintEvent * event)
{
QPainter painter(this);
painter.drawPixmap ( 1, 1, this->width( )-2, this->height()-2, QPixmap(":/Background.png") ); //自己做个单色图片
painter.drawText ( 3 , (this->height()/7)*5, this->text() );
}