PDA

View Full Version : Need help in setting the background of a QListPickSelector entry to an image ..



ahmadka
2nd July 2010, 18:19
Hi all .... I'm using a QListPickSelector in my project and the idea is that it displays a set of images, rather than a list of strings .. Now I have tried using the setIcon() function, which works, but the image displayed is very tiny .. !

Here is the output I get when I use the setIcon() function:

http://i46.tinypic.com/5tuexe.png

As you can see, the image displayed is *very* tiny ... I would like it to be filled throughout its respective list entry area (which is also rectangular) ...

I am trying to use the setBackground() function by passing it a QBrush, which has the said image as its texture .. but when I try this, nothing happens, the background is setting black as usual .. Can somebody help me with this .. ?

Here is one variable of many different combinations I have tried:


QBrush brush;
brush.setTexture(QPixmap(":/p1.png"));
brush.setStyle(Qt::TexturePattern);

QStandardItemModel *model = new QStandardItemModel(10,2);
int i,j,k;
for(j=0;j<=1;j++)
{
k=0;
for(i=0;i<=9;i++)
{
QStandardItem *item = new QStandardItem("Hello");
QStandardItem itemx;
item->setBackground(brush);
k+=5;
model->setItem(i,j,item);
}
}
canvasBackgroundTypeSelector->setModel(model);

I really need help with this ..

ahmadka
3rd July 2010, 11:17
Can someone help me with this please ?