Results 1 to 10 of 10

Thread: Cannot assign to pixmap during painting

  1. #1
    Join Date
    Sep 2010
    Posts
    6
    Qt products
    Qt4
    Platforms
    Windows

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Cannot assign to pixmap during painting

    What error do you get? And there is no need to create a temporary pixmap on the heap. And you are surely looking for [CODE][/CODE].

  3. #3
    Join Date
    Sep 2010
    Posts
    6
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Cannot assign to pixmap during painting

    Error msg that i get is fallowing:

    QPixmap:perator=: Cannot assign to pixmap during painting

    I started C++ and Qt just few weeks ago.

    Qt Code:
    1. QPixmap *bImage = new QPixmap(":/Tromso1.jpg");
    2.  
    3.  
    4. image->setPixmap(QPixmap(bImage->scaled(QSize(200,160), Qt::KeepAspectRatio)));
    5.  
    6. scene.addItem(image);
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Cannot assign to pixmap during painting

    Whats about
    Qt Code:
    1. image->setPixmap(bImage->scaled(QSize(200,160), Qt::KeepAspectRatio));
    To copy to clipboard, switch view to plain text mode 
    or
    Qt Code:
    1. QPixmap bImage(":/Tromso1.jpg");
    2. bImage.scale(QSize(200,160), Qt::KeepAspectRatio);
    3. image->setPixmap(bImage);
    To copy to clipboard, switch view to plain text mode 

  5. #5
    Join Date
    Sep 2010
    Posts
    6
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Cannot assign to pixmap during painting

    same problem...

    i was googling and found that i am not the only one with this problem but didn't see any solutions to this.

  6. #6
    Join Date
    Sep 2010
    Posts
    6
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Cannot assign to pixmap during painting

    Also, i do this inside constructor.

  7. #7
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Cannot assign to pixmap during painting

    Where are you creating image ?
    QGraphicsPixmapItem *image = new QGraphicsPixmapItem();

  8. #8
    Join Date
    Sep 2010
    Posts
    6
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Cannot assign to pixmap during painting

    i found what was the problem

  9. #9
    Join Date
    Feb 2016
    Posts
    5
    Qt products
    Qt5

    Default Re: Cannot assign to pixmap during painting

    In my case, I called scene()->clear() before setPixmap(). So, all pointers to items becomes invalid;

  10. #10
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Cannot assign to pixmap during painting

    I am sure the original poster is delighted to see this answer, 5 1/2 years later.

Similar Threads

  1. Scale an image and assign it to a QPushButton
    By harmodrew in forum Newbie
    Replies: 2
    Last Post: 10th August 2010, 11:46
  2. How to assign printerName in OpenPrinterW function
    By Prabha in forum Qt Programming
    Replies: 0
    Last Post: 2nd August 2010, 06:26
  3. assign problem with array of QTcpSocket
    By radeberger in forum Qt Programming
    Replies: 6
    Last Post: 1st May 2010, 16:03
  4. boost::assign
    By Sivert in forum General Programming
    Replies: 0
    Last Post: 2nd May 2007, 00:23
  5. I can't assign TableView signals...
    By tomek in forum Newbie
    Replies: 5
    Last Post: 9th January 2006, 21:04

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.