Results 1 to 7 of 7

Thread: Qt and OpenGl (I'm lost)

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2010
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Qt and OpenGl (I'm lost)

    Sorry to bump this, I really need help figuring this out otherwise I can't even get started.

    Maybe if you don't feel like answering my question, please reply with a link to some tutorial or example that would help me understand why my opengl calls are not working outside paintGL.

    Sorry again for the bump and thanks in advance.

  2. #2
    Join Date
    Feb 2007
    Location
    Karlsruhe, Germany
    Posts
    469
    Thanks
    17
    Thanked 90 Times in 88 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt and OpenGl (I'm lost)

    Hi!

    To my knowledge that's exactly how it's supposed to work. Why do you want to mix philosophies here? paintGL is fine for pure raw openGL.

    Use a widgets paintevent if you want to use QPainter. BTW: Qt's OpenGL QPainter implementation is quite good. So it might be a lot easier and more portable to use QPainter and use QGraphicsView with an OpenGL Viewport.

    Have a look at this: http://www.qtcentre.org/threads/2999...ht=#post140754

    Maybe you should describe what you want to do, and then we can find a solution.

    Johannes

  3. #3
    Join Date
    Sep 2010
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Qt and OpenGl (I'm lost)

    Hi JohannesMunk,

    Basically I want to create an application to illustrate certain aspects of linear algebra : draw vectors, planes, vector/dot product, point closer to a line, etc. I am mostly doing this to learn, I love math et want to learn Qt and OpenGL to a higher level (this is the reason for mixing the philosophies).

    I will have a look at the link you posted as soon as I get home and post back. Thanks a lot.

  4. #4
    Join Date
    Feb 2007
    Location
    Karlsruhe, Germany
    Posts
    469
    Thanks
    17
    Thanked 90 Times in 88 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt and OpenGl (I'm lost)

    Ok! Then I would highly recommend to use the comfortable opengl wrapping that QPainter allows:

    In another thread just yesterday I set up a simple OpenGL GraphicsView:

    http://www.qtcentre.org/threads/3424...476#post158476

    Instead of a button-widget you will add lots of custom QGraphicsItems for the different mathematical objects.

    Use scene->addItem(new Vector(QVector3D(..)));

    Qt Code:
    1. class Vector : public QGraphicsItem
    2. {
    3. public:
    4. Vector(QVector3D a);
    5. QRectF boundingRect() const{ return QRectF( ... ); }
    6.  
    7. void paint(QPainter *painter, const QStyleOptionGraphicsItem *item, QWidget *widget)
    8. {
    9. painter->drawLine(.. );
    10. }
    11. };
    To copy to clipboard, switch view to plain text mode 

    Let me know if you run into more problems!

    Joh

Similar Threads

  1. Hightlight not lost
    By wirasto in forum Qt Programming
    Replies: 0
    Last Post: 5th August 2010, 13:16
  2. Focus lost
    By franco.amato in forum Qt Programming
    Replies: 1
    Last Post: 25th January 2010, 22:07
  3. Completely lost!!!
    By Zuks in forum Newbie
    Replies: 4
    Last Post: 2nd December 2009, 09:58
  4. lost signals ?
    By deepinlife in forum Qt Programming
    Replies: 3
    Last Post: 17th June 2008, 10:11
  5. Lost widget
    By anli in forum Qt Programming
    Replies: 6
    Last Post: 29th July 2006, 19:02

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.