Results 1 to 9 of 9

Thread: qGLWidget

  1. #1
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default qGLWidget

    HI,
    I have a question.
    I'd like to show in my application 3 GLView that show different object...Do I code 3 different GL class or what?
    Thanks
    Regards

  2. #2
    Join Date
    Feb 2006
    Location
    US
    Posts
    173
    Thanks
    16
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: qGLWidget

    Do you mean 3 different class instances?

  3. #3
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: qGLWidget

    instances? it mean 3 different class declarations in 3 different header files that everyone will have an instance. If 3 widget must show 3 different objects I must to do this?
    Regards

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

    Default Re: qGLWidget

    No, why? If you tell your class how to draw three different scenes, you can use it multiple times.

  5. #5
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: qGLWidget

    I thinks you says something so:
    Qt Code:
    1. myWidget:: paintGL(){
    2. .....
    3. if (this== mywidget1) drawCube()
    4. if (this== mywidget2) drawCube()
    5. }
    To copy to clipboard, switch view to plain text mode 
    I have the way to retrieve myWidget1 pointer..but have you other idea?
    thanks.
    Regards

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

    Default Re: qGLWidget

    More likely something like:

    Qt Code:
    1. class MyGLWidget : public QGLWidget {
    2. public:
    3. MyGLWidget(int which, QWidget *p) : QGLWidget(p){ _which = which; }
    4. void paintGL(){
    5. switch(_which){
    6. case 0: drawCube(); break;
    7. case 1: drawCone(); break;
    8. case 2: drawSphere(); break;
    9. default: drawTeaPot();
    10. }
    11. }
    12. // ...
    13. private:
    14. int _which;
    15. };
    To copy to clipboard, switch view to plain text mode 

  7. #7
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: qGLWidget

    sorry, where is the increment of wich parameter?
    Regards

  8. #8
    Join Date
    Feb 2006
    Location
    US
    Posts
    173
    Thanks
    16
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: qGLWidget

    I didn't mean to complicate things by asking multiple class instances question.

    Typically, I have a single scene graph instance ... passing the top-level scene graph node to each window. Each window is able to render different portions of the scene graph by using different cull masks. In this case I have multiple instances of a single class (something that renders a scene via OpenGL widget and a cull mask). Hope this makes more sense.

    It seems to me this is the concept that wysota is trying to demonstrate. You can filter what you want to display based upon some filtering mechanism.

    Cheers,
    Ben

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

    Default Re: qGLWidget

    Quote Originally Posted by mickey
    sorry, where is the increment of wich parameter?
    What increment? You pass the value of "which" in the class constructor and based upon that the widget renders different scenes.

Similar Threads

  1. Replies: 1
    Last Post: 21st November 2008, 07:00
  2. QFileDialog QGLWidget crashes
    By SenSej in forum Newbie
    Replies: 1
    Last Post: 17th October 2008, 17:06
  3. Replies: 4
    Last Post: 7th May 2008, 00:01
  4. QGLWidget resize problem.
    By anderl in forum Qt Programming
    Replies: 2
    Last Post: 22nd January 2008, 08:57
  5. QGLWidget on another QGLWiget
    By showhand in forum Qt Programming
    Replies: 1
    Last Post: 23rd October 2006, 09:59

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.