Active Topics

 


Reply
Thread Tools
Posts: 341 | Thanked: 57 times | Joined on Nov 2009
#1
Hi all ... I wanted to know if its possible to have a QMaemo5ListPickSelector but one which displays rectangular images as list items instead of text ? Is this possible ? If not, is there any other list-like object in Qt which can show images as items instead of text ?
 
Posts: 180 | Thanked: 76 times | Joined on May 2010
#2
You can set icon for QStandardItem: http://doc.qt.nokia.com/qt-maemo-4.6...m.html#setIcon
 
Posts: 341 | Thanked: 57 times | Joined on Nov 2009
#3
Yes but I tried using QStandardItem once before, and the problem I faced was that nothing actually showed up on the screen !?

Full details on this problem are here: http://talk.maemo.org/showpost.php?p=732549&postcount=4
 
Posts: 3,617 | Thanked: 2,412 times | Joined on Nov 2009 @ Cambridge, UK
#4
Originally Posted by ahmadka View Post
Yes but I tried using QStandardItem once before, and the problem I faced was that nothing actually showed up on the screen !?

Full details on this problem are here: http://talk.maemo.org/showpost.php?p=732549&postcount=4
Looking at that again now - you appear to be creating the QStandarditemModel as a local variable (i.e. on the stack), so it will be destroyed when it goes out of context. I had a similar issue using PyQt. Have you tried creating it on the heap instead (i.e. QStandardItem *model = new QStandardItemModel(10,2))?
 

The Following User Says Thank You to Rob1n For This Useful Post:
Posts: 341 | Thanked: 57 times | Joined on Nov 2009
#5
Originally Posted by Rob1n View Post
Looking at that again now - you appear to be creating the QStandarditemModel as a local variable (i.e. on the stack), so it will be destroyed when it goes out of context. I had a similar issue using PyQt. Have you tried creating it on the heap instead (i.e. QStandardItem *model = new QStandardItemModel(10,2))?
Alright I just tried that and it worked .. I'm surprised why I didn't see such a silly error before :P

Anyways, I have another question .. Although images are beings displayed as icons now, they are *very* small !! I actually would like the entire index to be filled with the image itself, instead of just having a much smaller version of the image as an icon next to some text .. Here is what its looking like now:



I want that tiny rectangular icon to fill up the entire entry (which is rectangular too) ..

Can this be done ?
 
Posts: 3,617 | Thanked: 2,412 times | Joined on Nov 2009 @ Cambridge, UK
#6
The only thing I can see that might work is to do it via setBackground.
 
Posts: 341 | Thanked: 57 times | Joined on Nov 2009
#7
Originally Posted by Rob1n View Post
The only thing I can see that might work is to do it via setBackground.
Yeah thats what I thought too, but its not working for some reason .. This is what I'm trying:

Code:
            QImage *bg = new QImage(":/p1.png");
            QBrush *brush = new QBrush(*bg);    
            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");
                    item->setForeground(*brush);
                    model->setItem(i,j,item);
                }
            }
            canvasBackgroundTypeSelector->setModel(model);
EDIT: In the above code I'm setting the foreground instead of background .. I did this because I tried setting the background first, but it didn't do anything .. i tried it on the foreground then to see if the foreground text gets written using the texture from the image, but instead the text was just black instead of white now .. I'm wondering if the image itself is being loaded properly or not ..

Last edited by ahmadka; 2010-07-02 at 15:50.
 
Posts: 341 | Thanked: 57 times | Joined on Nov 2009
#8
Does anyone have any clues why the above code isn't working for me ?
 
Reply


 
Forum Jump


All times are GMT. The time now is 00:24.