Results 1 to 5 of 5

Thread: problem with displaying QGLWidget in QWidget made in desinger

  1. #1
    Join Date
    Feb 2011
    Posts
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default problem with displaying QGLWidget in QWidget made in desinger

    hi dear,
    I am using qt 4.7.1 and qt-creator 2.0.1. I have made a qglwidget.h and qglwidget.cpp. Then I made a widget in designer, right click it, selected promote to, then in base class I select "QWidget", in Promoted class name I wrote QGLWidget and in header file I wrote qglwidget.h
    Now the problem is that how can I display my qglwidet.cpp code in the widget, which I made through designer. When I run my project the widget (to which I promote qtwidget) is displaying a black screen.
    Kindly tell me that how can I display my code in that widget.

    Thank you very much

  2. #2
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: problem with displaying QGLWidget in QWidget made in desinger

    Have you read the QGLWidget docs ? You need to put your OpenGL code in paintGL(), initializeGL() and resizeGL() methods (there is an example in documentation).

  3. #3
    Join Date
    Feb 2011
    Posts
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: problem with displaying QGLWidget in QWidget made in desinger

    yes, I have already written my code in these functions. And if I create a new instance of qglwidet instance then it works fine. The problem is that how should I show it in widget made in desinger

  4. #4
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: problem with displaying QGLWidget in QWidget made in desinger

    in Promoted class name I wrote QGLWidget
    Ok, so this is the problem - you need to provide your WidgetClassName instead of QGLWidget, because now you are adding default QGLWidget to your ui.
    I have made a qglwidget.h and qglwidget.cpp
    I'd also suggest changing your file names.

  5. #5
    Join Date
    Feb 2011
    Posts
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: problem with displaying QGLWidget in QWidget made in desinger

    Quote Originally Posted by stampede View Post
    Ok, so this is the problem - you need to provide your WidgetClassName instead of QGLWidget, because now you are adding default QGLWidget to your ui.

    I'd also suggest changing your file names.
    Thank you so much. My problem has been solved by changing my filenames.

Similar Threads

  1. QWidget/QGlwidget ( + window opacity )
    By medved6 in forum Qt Programming
    Replies: 0
    Last Post: 5th October 2010, 06:14
  2. Render QWidget within QGLWidget
    By crazymonkey in forum Newbie
    Replies: 29
    Last Post: 26th September 2010, 13:54
  3. Replies: 1
    Last Post: 23rd April 2009, 09:05
  4. Displaying QWidget from a function.
    By raghvendramisra in forum Qt Programming
    Replies: 2
    Last Post: 23rd January 2008, 04:02
  5. Transparent QWidget on QGLWidget
    By showhand in forum Qt Programming
    Replies: 2
    Last Post: 27th November 2006, 01:00

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.