Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 7

Qt-interest Archive, March 2002
Pb with a widget in a QVBox


Message 1 in thread

Hi all,

I have a little problem with a widget :

I've developped a QWidget derived class to integrate an OpenGL based viewer ( 
from OpenCASCADE http://www.opencascade.org ).

Basically, I take the winId handle from this widget, and create with it some 
classes of OpenCASCADE to map the 3d display of OpenCASCADE to my widget.

The problem is that this widget works fine if it is displayed "alone" , but 
not in a layout :

int main ( int argc , char** argv)
{
  QApplication a(argc,argv);
  
#if 0
  //this one doesnt work
  QVBox* vb = new QVBox();
  vb->resize(300,300);
  QLabel* l1 = new QLabel("L1",vb);
  QOCCWidget* w = new QOCCWidget(vb);
  QLabel* l2 = new QLabel("L2",vb);
  a.setMainWidget(vb);
  vb->show();
#else
  //this one works
  QOCCWidget* w = new QOCCWidget();
  w->show();
#endif
  a.exec();
}

Do I need to do something special to have my widget working ?
I've tried to inherits from QGLWidget ( because my widget uses OpenGL ), but 
it is the same problem.

Any ideas ?

TIA,

Stephane
http://www.exotk.org


Message 2 in thread

Hi all,

I found something interessant

If I initialize my OpenGL-based viewer in the first paintEvent, it's working 
fine.
If I initialize it in the constructor of my widget, it doesn't work.

So, I think the winID is not completly defined or is not valid in the 
constructor of the widget, if this widget is a part of a layout.

Could you confirm me that point ?
If it is really true, could you explain me why ?
And when in the event loop can I be sure that the winID is valid ?


TIA,

Stephane
http://www.exotk.org


On March 19, 2002 14:42, Stephane Routelous wrote:
> Hi all,
>
> I have a little problem with a widget :
>
> I've developped a QWidget derived class to integrate an OpenGL based viewer
> ( from OpenCASCADE http://www.opencascade.org ).
>
> Basically, I take the winId handle from this widget, and create with it
> some classes of OpenCASCADE to map the 3d display of OpenCASCADE to my
> widget.
>
> The problem is that this widget works fine if it is displayed "alone" , but
> not in a layout :
>
> int main ( int argc , char** argv)
> {
>   QApplication a(argc,argv);
>
> #if 0
>   //this one doesnt work
>   QVBox* vb = new QVBox();
>   vb->resize(300,300);
>   QLabel* l1 = new QLabel("L1",vb);
>   QOCCWidget* w = new QOCCWidget(vb);
>   QLabel* l2 = new QLabel("L2",vb);
>   a.setMainWidget(vb);
>   vb->show();
> #else
>   //this one works
>   QOCCWidget* w = new QOCCWidget();
>   w->show();
> #endif
>   a.exec();
> }
>
> Do I need to do something special to have my widget working ?
> I've tried to inherits from QGLWidget ( because my widget uses OpenGL ),
> but it is the same problem.
>
> Any ideas ?
>
> TIA,
>
> Stephane
> http://www.exotk.org