antartide
23rd March 2011, 17:21
Hello to all, sorry my english =)
My problem is that:
I set a background to my QTreeWidget,
I populate my tree with QTreeWidgetItems and i want to see the background trought the items.
Try with setStyleSheet of the TreeWidget:item : nothing how can i do?
TreeWidget:
void qtg_QTreeWidget::paintEvent(QPaintEvent *event)
{
QPainter painter(viewport());
QImage image("./background.png");
QRect rect(x(),y(),image.height (),image.width());
qDebug () <<"paint" << x() << y() << image.height () <<image.width();
painter.drawImage(rect, image);
painter.end();
QTreeWidget::paintEvent(event);
};
TreeWidgetItem
gui_laucher::gui_laucher(QWidget *parent)
: QWidget(parent)
{
setupTray();
int y= m_tray->geometry().y() ;
int x= m_tray->geometry().x() ;
setGeometry(x+3,y+3,300,320);
setAttribute(Qt::WA_TranslucentBackground);
QStringList labels;
labels << tr("Software");
m_treeWidget = new qtg_QTreeWidget(this);
setStyleSheet("QTreeView::item {background-color :rgba(255,255,255,0%);}");
xmlparser();
}
I also try this:
qtg_QTreeWidgetItem::qtg_QTreeWidgetItem(QTreeWidg etItem *parent) :
QTreeWidgetItem(parent)
{
m_pProcessPath="nopath";
m_pStringParameters="noparams";
setBackground(0,QBrush(Qt::transparent));
}
I never can see the picture trought the item =(
My problem is that:
I set a background to my QTreeWidget,
I populate my tree with QTreeWidgetItems and i want to see the background trought the items.
Try with setStyleSheet of the TreeWidget:item : nothing how can i do?
TreeWidget:
void qtg_QTreeWidget::paintEvent(QPaintEvent *event)
{
QPainter painter(viewport());
QImage image("./background.png");
QRect rect(x(),y(),image.height (),image.width());
qDebug () <<"paint" << x() << y() << image.height () <<image.width();
painter.drawImage(rect, image);
painter.end();
QTreeWidget::paintEvent(event);
};
TreeWidgetItem
gui_laucher::gui_laucher(QWidget *parent)
: QWidget(parent)
{
setupTray();
int y= m_tray->geometry().y() ;
int x= m_tray->geometry().x() ;
setGeometry(x+3,y+3,300,320);
setAttribute(Qt::WA_TranslucentBackground);
QStringList labels;
labels << tr("Software");
m_treeWidget = new qtg_QTreeWidget(this);
setStyleSheet("QTreeView::item {background-color :rgba(255,255,255,0%);}");
xmlparser();
}
I also try this:
qtg_QTreeWidgetItem::qtg_QTreeWidgetItem(QTreeWidg etItem *parent) :
QTreeWidgetItem(parent)
{
m_pProcessPath="nopath";
m_pStringParameters="noparams";
setBackground(0,QBrush(Qt::transparent));
}
I never can see the picture trought the item =(