Results 1 to 4 of 4

Thread: Best Qt class for a dynamic color grid

  1. #1
    Join Date
    Jan 2009
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Best Qt class for a dynamic color grid

    I'm working on porting an application I wrote in OpenGL (glut) to Qt. I'm very happy with what I've seen of Qt so far. There seems to be many ways that I can do this and I'll be using this project for years, so I'm looking for some expert advice on what the Best way to do it would be.

    I have a data visualization that is a grid of squares, each of which are assigned a color. Basically, I have a grid of pixels, but they aren't always 1:1 with screen pixels. I display each square in the order that you would display pixels in an image, starting at upper left, moving to the right until I reach the width at which point I wrap to the next line. The catch is that the width is adjustable by the user so the "pixels" can migrate around on the screen. The visualization is rectangular, but the dimensions change based on user input.

    Design priorities:
    1) Layout can be easily changed
    2) Runs in real-time even with 100,000+ "pixels" on the screen
    3) Should be able to smoothly zoom in an out (basically scale the image).
    4) Ability to easily select 1 "pixel" using mouse input.

    The ability to select 1 pixel with a mouse is last on the list because zooming in/out and changing the width are used >100 times more often. If need be I could capture what screen pixel was clicked on and do the math to convert that to data points myself.

    I've been looking at the Qt example Graphic View > Diagram Scene as a good starting point for the kind of interface I'm shooting for. I can see using Bitmap, QPixelMap, a group of QGraphicsPolygonItem or several others. I'll probably implement my own class that either inherits or contains a Qt class. Thanks for the advice. Making the right decision here will make a big difference to me.

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

    Default Re: Best Qt class for a dynamic color grid

    Is there a reason to leave OpenGL behind and go for raster graphics? If not then you can use OpenGL with Qt as well.

  3. #3
    Join Date
    Jan 2009
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Best Qt class for a dynamic color grid

    Quote Originally Posted by wysota View Post
    Is there a reason to leave OpenGL behind and go for raster graphics? If not then you can use OpenGL with Qt as well.
    OpenGL compatibility is one of the reasons I picked Qt. 95% of all I do in this program is 2D though so my thought was that blitting pixels onto the screen would be much faster especially for very large datasets. My current OpenGL implementation simply treats each pixels and a square polygon with a solid color. This was easy to program but it becomes brain dead slow when I have 1 million polygons on the screen. I was considering simply writing a texture to a spot in memory and then having a single large rectangular polygon that gets texture mapped. While I'm making these improvements, I figured it would be a good time to switch to Qt.

    I am thinking the Qt version of what I just described would be to have a QGraphicsPolygonItem painted with a QBrush constructed with a QPixelMap (or Bitmap?) to basically texture map the thing on. I will still want to do some 3D stuff in the future so I'm planning on having an OpenGL window but I was thinking that utilizing the Qt 2D graphics would be useful for my primary goal.

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

    Default Re: Best Qt class for a dynamic color grid

    With Qt you can freely combine 2D and 3D graphics, even inside a single widget.

Similar Threads

  1. Replies: 3
    Last Post: 27th December 2008, 19:34
  2. class in the class
    By baray98 in forum General Programming
    Replies: 2
    Last Post: 23rd July 2008, 07:01
  3. class QHBoxLayout
    By csvivek in forum Installation and Deployment
    Replies: 2
    Last Post: 10th April 2008, 07:57
  4. How to use Signal through direct connection
    By santosh.kumar in forum Qt Programming
    Replies: 1
    Last Post: 14th December 2007, 07:07
  5. Replies: 2
    Last Post: 4th May 2006, 19:17

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