Results 1 to 2 of 2

Thread: QGraphicsItem recoloring really slow

  1. #1
    Join Date
    Dec 2008
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QGraphicsItem recoloring really slow

    Hi,

    I am writing a simple application with Qt. The application is to display about four thousand rectangles in different colors. The rectangles are implemented with QGraphicsRectItem. The window is implemented with QMainWindow. The window has several menus to allow users to display rectangles in selected colors.

    It's pretty fast to bring up the window with the default colors, in only a few seconds. However, it takes more than 2 minutes to do the recoloring after selecting an action from the menu.

    I double check the codes to make sure there is no hidden inefficient coding, and can't find any. I am new to Qt. So I am wondering whether there is any trap I should avoid in order to speed the recoloring.

    The application is written using Qt 4.4.0, compiled with GCC 4.2.2 , running on a Linux machine with 3GHz Pentium and 2G RAM.

    Thanks for any suggestion.

    Kai

  2. #2
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QGraphicsItem recoloring really slow

    Try to produce "a minimal compilable example exhibiting the problem".

    (Maybe it helps to setUpdatesEnabled(false) on the QGraphicsView before you start changing colors and back to true once you're done? Another problem might be that you perhaps call repaint() quite often. Hard to guess, that's why we ask for your help to help us help you.)

    HTH

Similar Threads

  1. destruction of QGraphicsItem
    By killkolor in forum Qt Programming
    Replies: 2
    Last Post: 5th December 2009, 10: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.