Results 1 to 1 of 1

Thread: Best Way to Draw Large Image

  1. #1
    Join Date
    May 2012
    Posts
    5
    Qt products
    Qt4

    Lightbulb Best Way to Draw Large Image

    Hi

    I'm making an application which draws multiple large image (maybe only parts of the image in a QMidSubWindow), so I'd like to know what's the best way, QGLWidget or QGraphicsScene ?

    BTW I got a issue on MAC 10.9.5 with Qt 4.8.7, the QGLWidget rendering area always occupies the whole client area, and always on top of any the other widgets. From my screenshot you will see the red area which is the GL canvas even overlaps the handle to scale window compared with the left. Maybe I'm using the old version ? Thanks !

    Qt Code:
    1. class LocalGLWidget : public QGLWidget
    2. {
    3. public:
    4.  
    5. LocalGLWidget(QWidget * Parent = NULL)
    6. :
    7. QGLWidget(QGLFormat(QGL::SampleBuffers | QGL::DirectRendering), Parent)
    8. {
    9. setAutoFillBackground(false);
    10. }
    11.  
    12. void initializeGL()
    13. {
    14. glViewport(0, 0, width(), height());
    15. glClearColor(0.0f, 1.0f, 0.0f, 0.0f);
    16. }
    17.  
    18. void paintGL()
    19. {
    20. glClear(GL_COLOR_BUFFER_BIT);
    21.  
    22. const int W = 512;
    23. const int H = 256;
    24.  
    25. glBegin(GL_QUADS);
    26. glColor3f(1.0f, 0.0f, 0.0f);glVertex2i(0, 0);
    27. glColor3f(0.0f, 1.0f, 0.0f);glVertex2i(W, 0);
    28. glColor3f(0.0f, 0.0f, 1.0f);glVertex2i(W, H);
    29. glColor3f(1.0f, 1.0f, 1.0f);glVertex2i(0, H);
    30. glEnd();
    31. }
    32.  
    33. void resizeGL(int W, int H)
    34. {
    35. glViewport(0, 0, W, H);
    36.  
    37. glMatrixMode(GL_PROJECTION);
    38. glLoadIdentity();
    39. gluOrtho2D(0, W, 0, H);
    40.  
    41. glMatrixMode(GL_MODELVIEW);
    42. glLoadIdentity();
    43. }
    44.  
    45. };
    46.  
    47. class LocalGLSubWindow : public QMdiSubWindow
    48. {
    49. public:
    50. LocalGLSubWindow(QWidget * Parent = NULL)
    51. :
    52. QMdiSubWindow(Parent)
    53. {
    54. setAutoFillBackground(false);
    55.  
    56. mGL = new LocalGLWidget();
    57.  
    58.  
    59. setWidget(mGL);
    60. }
    61.  
    62. LocalGLWidget * mGL;
    63. };
    To copy to clipboard, switch view to plain text mode 

    Screen Shot 2015-10-11 at 13.27.39.png
    Last edited by JediMaster; 11th October 2015 at 06:34.

Similar Threads

  1. Replies: 15
    Last Post: 24th July 2015, 23:33
  2. QML load large image
    By rstalin in forum Qt Quick
    Replies: 0
    Last Post: 15th December 2011, 10:13
  3. [Problem] Qt load large image
    By rstalin in forum Qt Programming
    Replies: 2
    Last Post: 11th October 2011, 19:21
  4. Replies: 6
    Last Post: 21st September 2009, 11:55
  5. Scroll large image in game
    By Morea in forum Qt Programming
    Replies: 2
    Last Post: 12th August 2006, 00:06

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.