pl01
5th April 2011, 16:14
Hi,
During a drag&drop I would like to display the icon and the text of the tree-item in the drag element. How can I do this ?
If I set the pixmap, it only display the icon... but not the text !
Thanks
Added after 28 minutes:
I have a partial solution, like this
void QShaderNavigator::mousePressEvent(QMouseEvent *event)
{
//---- Search for the selected definition
_dragTreeViewItem = itemAt(event->pos());
if (_dragTreeViewItem)
{
QVariant data = _dragTreeViewItem->data(0, 1);
if (data.isNull())
_dragTreeViewItem = 0;
else
{
const QPixmap image = iconShader.pixmap(QSize(16,16));
_dragPainter->drawPixmap(0, 0, 16, 16, image);
_dragPainter->drawText(QRect(20, 0, 170, 20), _dragTreeViewItem->text(0) );
}
}
QTreeWidget::mousePressEvent(event);
}
void QShaderNavigator::mouseMoveEvent(QMouseEvent * event)
{
...
drag->setPixmap( *_dragPixmap );
...
}
But the problem is that I have a big gray background in the Drag item !!!
During a drag&drop I would like to display the icon and the text of the tree-item in the drag element. How can I do this ?
If I set the pixmap, it only display the icon... but not the text !
Thanks
Added after 28 minutes:
I have a partial solution, like this
void QShaderNavigator::mousePressEvent(QMouseEvent *event)
{
//---- Search for the selected definition
_dragTreeViewItem = itemAt(event->pos());
if (_dragTreeViewItem)
{
QVariant data = _dragTreeViewItem->data(0, 1);
if (data.isNull())
_dragTreeViewItem = 0;
else
{
const QPixmap image = iconShader.pixmap(QSize(16,16));
_dragPainter->drawPixmap(0, 0, 16, 16, image);
_dragPainter->drawText(QRect(20, 0, 170, 20), _dragTreeViewItem->text(0) );
}
}
QTreeWidget::mousePressEvent(event);
}
void QShaderNavigator::mouseMoveEvent(QMouseEvent * event)
{
...
drag->setPixmap( *_dragPixmap );
...
}
But the problem is that I have a big gray background in the Drag item !!!