Results 1 to 3 of 3

Thread: problem in loading pixmap item to qgraphicslinearlayout

  1. #1
    Join Date
    Sep 2008
    Location
    Bangalore
    Posts
    659
    Thanks
    116
    Thanked 42 Times in 41 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default problem in loading pixmap item to qgraphicslinearlayout

    hi friends,
    i was trying to load the pixmapItem in a graphicsview using QLinearlayout . its like adding pixmap item with qfuturewatcher

    Qt Code:
    1. imageScaling = new QFutureWatcher<QImage>(this);
    2. connect(imageScaling, SIGNAL(resultReadyAt(int)), SLOT(showImage(int)));
    To copy to clipboard, switch view to plain text mode 


    Qt Code:
    1. View::setSceneLayout()
    2. {
    3. m_scene->clear();
    4. m_baseLayout = new QGraphicsLinearLayout(Qt::Vertical);
    5. m_baseLayout->setSpacing(8);
    6. m_container = new QGraphicsWidget;
    7. m_container->setLayout(m_baseLayout);
    8.  
    9. }
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. void
    2. View::addItems( QStringList list ) //const QImage image, const QString &fileName)
    3. {
    4.  
    5.  
    6. if (imageScaling->isRunning()) {
    7. imageScaling->cancel();
    8. imageScaling->waitForFinished();
    9. }
    10.  
    11. m_list = list;
    12.  
    13. imageScaling->setFuture(QtConcurrent::mapped(list, CheatScaled));
    14.  
    15. }
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. CheatScaled( const QString &imageFileName)
    2. {
    3. //scaling image
    4. return qimage;
    5. }
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. void
    2. View::showImage(int num)
    3. {
    4. PixmapItem *pixItem = new PixmapItem(imageScaling->resultAt(num));
    5. m_scene->addItem(pixItem);
    6. m_baseLayout->addItem(pixItem);
    7.  
    8.  
    9. }
    To copy to clipboard, switch view to plain text mode 

    the image is adding clearly to the graphicsview . but when the image added to the layout it shows a ghost image or a small portion of the loading image in the first item..but only at the loading time .. as it looks like flickering. for every item it adding. it is showing some kind of flickering but after it loads the item it looks normal ..

    sorry i cant explain the problem clearly ..
    please hep me in avoiding this effect ..
    "Behind every great fortune lies a crime" - Balzac

  2. #2
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: problem in loading pixmap item to qgraphicslinearlayout

    So you have so many images (and/or they are big) that you need to rescale them in separate thread ?
    How frequent are the updates ? Maybe you could try just:
    Qt Code:
    1. setUpdatesEnabled(false);
    2. addItemsInGuiThread(...);
    3. setUpdatesEnabled(true);
    To copy to clipboard, switch view to plain text mode 
    I'm just wondering if you really need separate threads to update the gui.
    btw.
    connect(imageScaling, SIGNAL(resultReadyAt(int)), SLOT(showImage(int)));
    a typo, right ?

  3. The following user says thank you to stampede for this useful post:

    wagmare (11th October 2013)

  4. #3
    Join Date
    Sep 2008
    Location
    Bangalore
    Posts
    659
    Thanks
    116
    Thanked 42 Times in 41 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: problem in loading pixmap item to qgraphicslinearlayout

    yeah its in the constructor of my view ..
    "Behind every great fortune lies a crime" - Balzac

Similar Threads

  1. Replies: 8
    Last Post: 19th July 2011, 10:52
  2. Replies: 1
    Last Post: 19th April 2011, 11:17
  3. To find X, Y position of a pixmap item in Graphicsscene
    By augusbas in forum Qt Programming
    Replies: 2
    Last Post: 21st January 2011, 06:09
  4. Pixmap height / width without loading it
    By bunjee in forum Qt Programming
    Replies: 1
    Last Post: 29th November 2007, 07:10
  5. Showing Pixmap as a QListWidget Item
    By vishal.chauhan in forum Qt Programming
    Replies: 1
    Last Post: 1st February 2007, 12:25

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.