Results 1 to 3 of 3

Thread: QPainter native painting

  1. #1
    Join Date
    Dec 2008
    Location
    Poland
    Posts
    383
    Thanks
    52
    Thanked 42 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Android

    Default QPainter native painting

    Hello,
    I have problem with QPainter and native painting.
    In short it doesn't work.

    For example I use in paintEvent() this code to draw simple quad:

    Qt Code:
    1. void myWidget::paintEvent(QPaintEvent *e)
    2. {
    3. QPainter p(this);
    4. p.beginNativePainting();
    5.  
    6. glBegin(GL_QUADS);
    7. glColor3ub(0,0,255);
    8. glVertex2d(0, 0);
    9. glVertex2d(0, height());
    10. glColor3ub(255,0,0);
    11. glVertex2d(width(), height());
    12. glVertex2d(width(), 0);
    13. glEnd();
    14.  
    15. qDebug() << "--- OpenGL paint" << this->width() << this->height() << p.paintEngine()->type();
    16.  
    17. p.endNativePainting();
    18.  
    19. }
    To copy to clipboard, switch view to plain text mode 

    paintEngine()->type() is always 10 == Rester.

    So the question:
    how to initialize OpenGL painting with the QPainter? (qt 4.8.1)

    I don't know if it's lack of the sleep but with the 4.7. this worked fine.
    In the near future - corporate networks reach out to the stars. Electrons and light flow throughout the universe.
    The advance of computerization however, has not yet wiped out nations and ethnic groups.

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

    Default Re: QPainter native painting

    Does myWidget inherit QGLWidget?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Dec 2008
    Location
    Poland
    Posts
    383
    Thanks
    52
    Thanked 42 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QPainter native painting

    No.

    I see (after sleep) where the problem lies.
    QGLContext is non existing, in 4.7 I used setGraphicsSybstem opengl - qt created one for MainWindow automatically so I could do native in non OGL widget.

    Sub classing QGLWidget solves problem.
    In the near future - corporate networks reach out to the stars. Electrons and light flow throughout the universe.
    The advance of computerization however, has not yet wiped out nations and ethnic groups.

Similar Threads

  1. Replies: 2
    Last Post: 5th December 2011, 18:07
  2. Replies: 2
    Last Post: 8th October 2011, 14:50
  3. Replies: 19
    Last Post: 26th November 2008, 20:54
  4. Replies: 3
    Last Post: 30th April 2006, 20:22
  5. Trouble with image painting (QPainter + QImage)
    By krivenok in forum Qt Programming
    Replies: 1
    Last Post: 4th February 2006, 21: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.