Results 1 to 17 of 17

Thread: Unable to set the view port for graphicsview

  1. #1
    Join Date
    Oct 2011
    Posts
    48
    Thanks
    6
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Unable to set the view port for graphicsview

    Hi,

    If I am using setviewport for the graphicsview , I am getting a transparent screen .

    view->setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));

    Can anyone please suggest any solution?


    Thanks

  2. #2
    Join Date
    Apr 2011
    Location
    Russia
    Posts
    85
    Thanks
    2
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Unable to set the view port for graphicsview

    Qt Code:
    1. MainWindow::MainWindow( QWidget *parent ):
    2. QMainWindow( parent )
    3. {
    4. GraphicsView *view = new GraphicsView;
    5. view->setViewport( new QGLWidget( QGLFormat( QGL::SampleBuffers | QGL::AlphaChannel | QGL::Rgba ) ) );
    6. view->setViewportUpdateMode( QGraphicsView::FullViewportUpdate );
    7. view->setScene( new OpenGLScene );
    8.  
    9. resize( 320, 240 );
    10. setCentralWidget( view );
    11. }
    12.  
    13. GraphicsView::GraphicsView()
    14. {
    15. }
    16.  
    17. void GraphicsView::resizeEvent( QResizeEvent *e )
    18. {
    19. if (scene())
    20. scene()->setSceneRect( QRect( QPoint( 0, 0 ), e->size() ) );
    21.  
    22. QGraphicsView::resizeEvent(e);
    23. }
    24.  
    25. OpenGLScene::OpenGLScene()
    26. {
    27. }
    28.  
    29. OpenGLScene::~OpenGLScene()
    30. {
    31. }
    32.  
    33. void OpenGLScene::drawBackground( QPainter */*painter*/, const QRectF &/*rect*/ )
    34. {
    35. glClearColor( 1.0f, 1.0f, 1.0f, 1.0f );
    36. glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
    37.  
    38. glMatrixMode( GL_PROJECTION );
    39.  
    40. glPushMatrix();
    41. glLoadIdentity();
    42. glViewport( 0, 0, int( width() ), int( height() ) );
    43. //glOrtho( -width() / 2.0, width() / 2.0, -height() / 2.0, height() / 2.0, -1.0, 1000.0 );
    44. glOrtho( 0.0, width(), height(), 0.0, -1.0, 1000.0 );
    45.  
    46. glMatrixMode( GL_MODELVIEW );
    47. glPushMatrix();
    48. glLoadIdentity();
    49. // DRAW HERE
    50. glPopMatrix();
    51. glPopMatrix();
    52.  
    53. //QTimer::singleShot( 1, this, SLOT(update()) );
    54. }
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Oct 2011
    Posts
    48
    Thanks
    6
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Unable to set the view port for graphicsview

    Thanks Jonny . I compiled and ran the code. But I am getting a transparent screen again..

    With the following debug outputs..
    X Error: BadRequest (invalid request code or no such operation) 1
    Extension: 136 (Uknown extension)
    Minor opcode: 19 (Unknown request)
    Resource id: 0x64
    X Error: BadRequest (invalid request code or no such operation) 1
    Extension: 136 (Uknown extension)
    Minor opcode: 19 (Unknown request)
    Resource id: 0x64
    X Error: BadRequest (invalid request code or no such operation) 1
    Extension: 136 (Uknown extension)
    Minor opcode: 14 (Unknown request)
    Resource id: 0x64
    QGLTempContext: No GL capable X visuals available.
    X Error: BadRequest (invalid request code or no such operation) 1
    Extension: 136 (Uknown extension)
    Minor opcode: 19 (Unknown request)
    Resource id: 0x64
    X Error: BadRequest (invalid request code or no such operation) 1
    Extension: 136 (Uknown extension)
    Minor opcode: 19 (Unknown request)
    Resource id: 0x64
    X Error: BadRequest (invalid request code or no such operation) 1
    Extension: 136 (Uknown extension)
    Minor opcode: 14 (Unknown request)
    Resource id: 0x64
    X Error: BadRequest (invalid request code or no such operation) 1
    Extension: 136 (Uknown extension)
    Minor opcode: 19 (Unknown request)
    Resource id: 0x64
    X Error: BadRequest (invalid request code or no such operation) 1
    Extension: 136 (Uknown extension)
    Minor opcode: 19 (Unknown request)
    Resource id: 0x64
    X Error: BadRequest (invalid request code or no such operation) 1
    Extension: 136 (Uknown extension)
    Minor opcode: 14 (Unknown request)
    Resource id: 0x64
    X Error: BadRequest (invalid request code or no such operation) 1
    Extension: 136 (Uknown extension)
    Minor opcode: 19 (Unknown request)
    Resource id: 0x64
    X Error: BadRequest (invalid request code or no such operation) 1
    Extension: 136 (Uknown extension)
    Minor opcode: 19 (Unknown request)
    Resource id: 0x64
    X Error: BadRequest (invalid request code or no such operation) 1
    Extension: 136 (Uknown extension)
    Minor opcode: 14 (Unknown request)
    Resource id: 0x64
    X Error: BadRequest (invalid request code or no such operation) 1
    Extension: 136 (Uknown extension)
    Minor opcode: 19 (Unknown request)
    Resource id: 0x64
    X Error: BadRequest (invalid request code or no such operation) 1
    Extension: 136 (Uknown extension)
    Minor opcode: 19 (Unknown request)
    Resource id: 0x64
    X Error: BadRequest (invalid request code or no such operation) 1
    Extension: 136 (Uknown extension)
    Minor opcode: 14 (Unknown request)
    Resource id: 0x64
    X Error: BadRequest (invalid request code or no such operation) 1
    Extension: 136 (Uknown extension)
    Minor opcode: 19 (Unknown request)
    Resource id: 0x64
    X Error: BadRequest (invalid request code or no such operation) 1
    Extension: 136 (Uknown extension)
    Minor opcode: 19 (Unknown request)
    Resource id: 0x64
    X Error: BadRequest (invalid request code or no such operation) 1
    Extension: 136 (Uknown extension)
    Minor opcode: 14 (Unknown request)
    Resource id: 0x64
    X Error: BadRequest (invalid request code or no such operation) 1
    Extension: 136 (Uknown extension)
    Minor opcode: 19 (Unknown request)
    Resource id: 0x5600007
    X Error: BadRequest (invalid request code or no such operation) 1
    Extension: 136 (Uknown extension)
    Minor opcode: 19 (Unknown request)
    Resource id: 0x5600007
    X Error: BadRequest (invalid request code or no such operation) 1
    Extension: 136 (Uknown extension)
    Minor opcode: 14 (Unknown request)
    Resource id: 0x5600007
    QGLTempContext: No GL capable X visuals available.
    QGLContext::makeCurrent(): Cannot make invalid context current.
    In drwa
    QGLContext::makeCurrent(): Cannot make invalid context current.
    In drwa
    QGLContext::makeCurrent(): Cannot make invalid context current.
    In drwa
    QGLContext::makeCurrent(): Cannot make invalid context current.
    In drwa
    QGLContext::makeCurrent(): Cannot make invalid context current.
    In drwa
    QGLContext::makeCurrent(): Cannot make invalid context current.
    In drwa
    QGLContext::makeCurrent(): Cannot make invalid context current.
    In drwa


    Added after 24 minutes:


    My GLWidget is not valid bool result = widget->isValid(); returns false.

    What can I do to make it valid ?
    Last edited by A9am; 20th December 2012 at 06:16.

  4. #4
    Join Date
    Apr 2011
    Location
    Russia
    Posts
    85
    Thanks
    2
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Unable to set the view port for graphicsview

    Put here your project

    Try this in MainWindow:
    Qt Code:
    1. view = new GraphicsView;
    2.  
    3. wgt = new QGLWidget( QGLFormat( QGL::SampleBuffers | QGL::AlphaChannel | QGL::Rgba ) );
    4.  
    5. QGLFormat frm = wgt->format();
    6. frm.setSamples(4);
    7.  
    8. wgt->makeCurrent();
    9.  
    10. scene = new OpenGLScene( wgt );
    11.  
    12. view->setViewport( wgt );
    13. view->setViewportUpdateMode( QGraphicsView::FullViewportUpdate );
    14. view->setScene( scene );
    To copy to clipboard, switch view to plain text mode 

  5. #5
    Join Date
    Oct 2011
    Posts
    48
    Thanks
    6
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Unable to set the view port for graphicsview

    I tried the above code , I am getting a window plus the following output on execution .

    X Error: BadRequest (invalid request code or no such operation) 1
    Extension: 136 (Uknown extension)
    Minor opcode: 19 (Unknown request)
    Resource id: 0x64
    X Error: BadRequest (invalid request code or no such operation) 1
    Extension: 136 (Uknown extension)
    Minor opcode: 19 (Unknown request)
    Resource id: 0x64
    X Error: BadRequest (invalid request code or no such operation) 1
    Extension: 136 (Uknown extension)
    Minor opcode: 14 (Unknown request)
    Resource id: 0x64
    QGLTempContext: No GL capable X visuals available.
    X Error: BadRequest (invalid request code or no such operation) 1
    Extension: 136 (Uknown extension)
    Minor opcode: 19 (Unknown request)
    Resource id: 0x64
    X Error: BadRequest (invalid request code or no such operation) 1
    Extension: 136 (Uknown extension)
    Minor opcode: 19 (Unknown request)
    Resource id: 0x64
    X Error: BadRequest (invalid request code or no such operation) 1
    Extension: 136 (Uknown extension)
    Minor opcode: 14 (Unknown request)
    Resource id: 0x64
    X Error: BadRequest (invalid request code or no such operation) 1
    Extension: 136 (Uknown extension)
    Minor opcode: 19 (Unknown request)
    Resource id: 0x64
    X Error: BadRequest (invalid request code or no such operation) 1
    Extension: 136 (Uknown extension)
    Minor opcode: 19 (Unknown request)
    Resource id: 0x64
    X Error: BadRequest (invalid request code or no such operation) 1
    Extension: 136 (Uknown extension)
    Minor opcode: 14 (Unknown request)
    Resource id: 0x64
    X Error: BadRequest (invalid request code or no such operation) 1
    Extension: 136 (Uknown extension)
    Minor opcode: 19 (Unknown request)
    Resource id: 0x64
    X Error: BadRequest (invalid request code or no such operation) 1
    Extension: 136 (Uknown extension)
    Minor opcode: 19 (Unknown request)
    Resource id: 0x64
    X Error: BadRequest (invalid request code or no such operation) 1
    Extension: 136 (Uknown extension)
    Minor opcode: 14 (Unknown request)
    Resource id: 0x64
    X Error: BadRequest (invalid request code or no such operation) 1
    Extension: 136 (Uknown extension)
    Minor opcode: 19 (Unknown request)
    Resource id: 0x64
    X Error: BadRequest (invalid request code or no such operation) 1
    Extension: 136 (Uknown extension)
    Minor opcode: 19 (Unknown request)
    Resource id: 0x64
    X Error: BadRequest (invalid request code or no such operation) 1
    Extension: 136 (Uknown extension)
    Minor opcode: 14 (Unknown request)
    Resource id: 0x64
    X Error: BadRequest (invalid request code or no such operation) 1
    Extension: 136 (Uknown extension)
    Minor opcode: 19 (Unknown request)
    Resource id: 0x64
    X Error: BadRequest (invalid request code or no such operation) 1
    Extension: 136 (Uknown extension)
    Minor opcode: 19 (Unknown request)
    Resource id: 0x64
    X Error: BadRequest (invalid request code or no such operation) 1
    Extension: 136 (Uknown extension)
    Minor opcode: 14 (Unknown request)
    Resource id: 0x64
    QGLContext::makeCurrent(): Cannot make invalid context current.
    XIO: fatal IO error 11 (Resource temporarily unavailable) on X server "(m"
    after 495 requests (494 known processed) with 0 events remaining.



    The code below is used:


    QGLFormat *format =new QGLFormat(QGL::SampleBuffers | QGL::AlphaChannel | QGL::Rgba );
    bool res=format->hasOpenGL(); //returns true


    QGLContext *context = new QGLContext(*format);
    res = context->isValid(); //returns false


    bool result = widget->isValid(); //returns false

  6. #6
    Join Date
    Apr 2011
    Location
    Russia
    Posts
    85
    Thanks
    2
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Unable to set the view port for graphicsview

    Put minimal project here

  7. #7
    Join Date
    Oct 2011
    Posts
    48
    Thanks
    6
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Unable to set the view port for graphicsview

    Hi Jonny .. Even for OpenGl example"Hellogl" code from Qt I am getting a transparent screen.. So Please forget about my project. Atleast I should be able to get the sample output properly.

  8. #8
    Join Date
    Apr 2011
    Location
    Russia
    Posts
    85
    Thanks
    2
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Unable to set the view port for graphicsview

    Maybe reinstall Qt helps you

  9. #9
    Join Date
    Oct 2011
    Posts
    48
    Thanks
    6
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Unable to set the view port for graphicsview

    I have three different versions installed in my system Qt-4.5.2 , Qt-4.8.2 and Qt-4.7.2 . In all samples I am getting same output. Should I need to install any other libraries for OpenGL ??

  10. #10
    Join Date
    Apr 2011
    Location
    Russia
    Posts
    85
    Thanks
    2
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Unable to set the view port for graphicsview

    Quote Originally Posted by A9am View Post
    I have three different versions installed in my system Qt-4.5.2 , Qt-4.8.2 and Qt-4.7.2 . In all samples I am getting same output. Should I need to install any other libraries for OpenGL ??
    No.

    Try install new video drivers.

    Try put XInitThreads() function in constructor.

    http://stackoverflow.com/questions/5...l-applications

    Try to do something without using Qt Widgets. Purely in C++ and OpenGL.
    Last edited by Jonny174; 20th December 2012 at 10:51.

  11. #11
    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: Unable to set the view port for graphicsview

    I think this error message says it all:

    QGLTempContext: No GL capable X visuals available.
    You cannot use a GL format your graphics driver and X11 configuration don't support.
    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.


  12. #12
    Join Date
    Oct 2011
    Posts
    48
    Thanks
    6
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Unable to set the view port for graphicsview

    Hi,
    Now I installed a graphics card and driver on my system. OpenGL Examples are working with this. I have an application in which I am using the following part of code

    scene = new QGraphicsScene(this);

    scene->setSceneRect(QRectF(centerX-2000000, centerY-2000000, 4000000,4000000));

    view = new QGraphicsView(this);
    view->setScene(scene);
    view->setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
    view->setGeometry(0,0,viewRangeX,viewRangeY);
    view->setDragMode(QGraphicsView::ScrollHandDrag);
    view->centerOn(centerX,centerY);
    view->setBackgroundBrush(Qt::black);
    view->scale(viewRangeX/1000000,viewRangeX/1000000);

    view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff );
    view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysO ff);




    And I am adding a radar video item into this scene. The radar should scan the whole area (360 degrees).
    But when I am using the setviewport function (text in red) , the scan stops. Without this line its scanning properly. But I want to use the QGLWidget as viewport. Kindly give some suggestions.


    Thanks

  13. #13
    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: Unable to set the view port for graphicsview

    What if you call:

    Qt Code:
    1. view->setViewport(new QGLWidget);
    To copy to clipboard, switch view to plain text mode 
    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.


  14. #14
    Join Date
    Oct 2011
    Posts
    48
    Thanks
    6
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Unable to set the view port for graphicsview

    Same result with
    view->setViewport(new QGLWidget);


  15. #15
    Join Date
    Oct 2011
    Posts
    48
    Thanks
    6
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Unable to set the view port for graphicsview

    In one of the systems , the application was working fine with proper scan. But once I installed nvidia driver , the application is not working with setviewport.
    view->setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));



    And when I uninstalled the nvidia driver , application is running without any problem .
    Can anyone please tell me why this is happening??
    Last edited by A9am; 7th January 2013 at 06:37.

  16. #16
    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: Unable to set the view port for graphicsview

    Misconfigured driver? Which driver are you using, the proprietiary one?
    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.


  17. #17
    Join Date
    Oct 2011
    Posts
    48
    Thanks
    6
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Unable to set the view port for graphicsview

    Yes. The driver downloaded from the nvidia site

Similar Threads

  1. QWidget + QGraphicsView + OenGL view port
    By medved6 in forum Qt Programming
    Replies: 5
    Last Post: 30th March 2011, 07:55
  2. How to switch view in sliding/moving new view from right of device to the left
    By curiouswalker in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 16th November 2010, 11:55
  3. Unable to view images in an application created for Windows ce
    By mistertwister in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 4th March 2010, 19:23
  4. Graphicsview??
    By Screeze in forum Newbie
    Replies: 2
    Last Post: 5th July 2009, 17:01
  5. Replies: 5
    Last Post: 21st November 2007, 20:38

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.