Results 1 to 5 of 5

Thread: performance issue(QGV + QPixmap::grabWidget)

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    258
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android
    Thanks
    22
    Thanked 19 Times in 16 Posts

    Default Re: performance issue(QGV + QPixmap::grabWidget)

    Thanks for the reply wysota. According to your suggestions, I have changed the function createItems in the following way:
    Qt Code:
    1. for (int i=0; i<tabWidget->count(); i++) {
    2. foreach(QGraphicsItem *item, items) {
    3. delete(item);
    4. }
    5. invalidate(sceneRect());
    6. items.clear();
    7.  
    8. int batchSz = 4;
    9. for (int i=0; i<tabWidget->count(); i++) {
    10. QWidget *w = tabWidget->widget(i);
    11. QPixmap pm = QPixmap::grabWidget(w);
    12. pm = pm.scaled(300,200, Qt::IgnoreAspectRatio);
    13. ThumbnailItem * item = new ThumbnailItem(pm, i); // TODO Take size from config
    14. items << item;
    15. connect(item, SIGNAL(tabSelected(int)), tabWidget, SLOT(onTabSelected(int)));
    16. connect(item, SIGNAL(tabSelected(int)), this, SIGNAL(toggleThumbnailMode()));
    17. if (items.count() % batchSz == 0) {
    18. foreach(QGraphicsItem *i, items.mid(items.count()-4))
    19. addItem(i);
    20. QCoreApplication::processEvents();
    21. }
    22. }
    23. foreach(QGraphicsItem *i, items.mid(items.count() - items.count()%batchSz))
    24. addItem(i);
    25. }
    To copy to clipboard, switch view to plain text mode 
    Now the switch to thumbnail-mode is immediate which is a good thing. But, now the users see the items being created which is not optimal. Is it expensive to add some QGV Animation to hide this from the user? Maybe to display an opaque QGraphicsRectItem that covers the whole scene and then fading it out using QTimeLine in conjunction with QGraphicsItemAnimation?

    Thanx
    Last edited by momesana; 27th September 2007 at 12:31.

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.