Hi!
Im trying to create an transparant pixmap to use in a listview. The best result I get is to use createHeuristicMask which isn't good enough.
I have been trying to fill the pixmap with an transparent image first, but not succeceded.
Im using Qt 3.3 and here is the code that im trying to experiment with at the moment.
#include <qapplication.h>
#include <qlistview.h>
#include <qpainter.h>
#include <qpixmap.h>
#include <qbitmap.h>
int main ( int argc, char **argv )
{
QApplication app ( argc,argv );
QListView *listview=new QListView();
listview->addColumn ( "test" );
QListViewItem *item1=new QListViewItem ( listview );
item1->setText ( 0,"testing text" );
QListViewItem *item2=new QListViewItem ( listview );
QPixmap pixmap ( 150,50 );
pixmap.fill ( Qt::white );
QPainter painter ( &pixmap );
painter.drawText ( 15,15,"testing pixmap" );
painter.end();
pixmap.setMask(pixmap.createHeuristicMask());
item2->setPixmap ( 0,pixmap );
app.setMainWidget ( listview );
listview->show();
return app.exec();
}
Bookmarks