Results 1 to 20 of 21

Thread: pixmap or qimage second time usage in widgets ( platform S60 )

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2010
    Posts
    46
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Symbian S60

    Question pixmap or qimage second time usage in widgets ( platform S60 )

    I have come across a scenario where I have to load the same pixmap / same QImage onto two different widgets ( belonging to the same mainwindow ).

    First time I load a pixmap 1 on widget 1 , it works fine.
    Second time if I try to load the same pixmap ( or QImage ) on another widget ( say widget 2), the code just throws some error ( saying memory full ) or does not load the pixmap on widget 2.

    Ultimately I end up duplicating the png files i use to load the pixmaps, giving them distinct file names. Is there a solution to avoid this loading problem so that the I can use the same png file to be loaded any number of times ?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: pixmap or qimage second time usage in widgets ( platform S60 )

    Why not reuse the same image instead of loading it again?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    May 2010
    Posts
    46
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Symbian S60

    Question Re: pixmap or qimage second time usage in widgets ( platform S60 )

    I faced the same issue with the usage of the same pixmap more than once when adding it to a model class ( without loading ). Is there a solution to this ?

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: pixmap or qimage second time usage in widgets ( platform S60 )

    Please provide a minimal compilable example reproducing the problem.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    May 2010
    Posts
    46
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Symbian S60

    Question Re: pixmap or qimage second time usage in widgets ( platform S60 )

    The code segment for this is as shown below -

    Qt Code:
    1. gridLayout = new QGridLayout(mainwindow);
    2. gridLayout->setObjectName(QString::fromUtf8("gridLayout"));
    3. gridLayout->setContentsMargins(0, 0, 0, 0);
    4. label = new QLabel(gridLayout);
    5. label->setObjectName(QString::fromUtf8("label"));
    6. label->setPixmap(QPixmap(QString::fromUtf8("../folder/user_group_icon.bmp")));
    7.  
    8. gridLayout->addWidget(label, 0, 0, 1, 1);
    9.  
    10. label_2 = new QLabel(gridLayout);
    11. label_2->setObjectName(QString::fromUtf8("label_2"));
    12. label_2->setPixmap(QPixmap(QString::fromUtf8("../folder/user_group_icon.bmp")));
    13.  
    14. gridLayout->addWidget(label_2, 0, 1, 1, 1);
    To copy to clipboard, switch view to plain text mode 

    Here the gridLayout is added to a mainwindow & contains 2 labels. Both set the same bmp file as pixmap. The first label displays it but the second label does not. This problem occurs ONLY ON S60 ( not on windows ).

    Has anyone faced this issue before?

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: pixmap or qimage second time usage in widgets ( platform S60 )

    What if you do this:
    Qt Code:
    1. QPixmap pixmap(QString::fromUtf8("../folder/user_group_icon.bmp"));
    2. gridLayout = new QGridLayout(mainwindow);
    3. gridLayout->setObjectName(QString::fromUtf8("gridLayout"));
    4. gridLayout->setContentsMargins(0, 0, 0, 0);
    5. label = new QLabel(gridLayout);
    6. label->setObjectName(QString::fromUtf8("label"));
    7. label->setPixmap(pixmap);
    8.  
    9. gridLayout->addWidget(label, 0, 0, 1, 1);
    10.  
    11. label_2 = new QLabel(gridLayout);
    12. label_2->setObjectName(QString::fromUtf8("label_2"));
    13. label_2->setPixmap(pixmap);
    14.  
    15. gridLayout->addWidget(label_2, 0, 1, 1, 1);
    To copy to clipboard, switch view to plain text mode 
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. QImage::scaled takes long time
    By nrabara in forum Qt Programming
    Replies: 0
    Last Post: 15th December 2009, 12:19
  2. need some clarification on QImage and QRgb usage
    By kona in forum Qt Programming
    Replies: 5
    Last Post: 6th September 2008, 14:20
  3. CPU Time & Memory Usage in QThread or QProcess
    By Davidaino in forum Qt Programming
    Replies: 0
    Last Post: 11th July 2008, 19:15
  4. about qt/embedded widgets showing in ARM platform
    By xianshuiren in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 3rd December 2007, 05:48

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.