
Fri, 07/14/2006 - 17:11
Hello!
I need to draw a rectangle on the QGLWidget for selection by region on the OCC 3D Viewer. The problem is: when I drawing the rectangle using QPainter, I see the white backgrount of the parent Widget. In the Qt3 such problems was not appeared. At the OCC Qt3 samples they using the simple QWidget with some additional flags. But this did not work on Qt4, only QGLWidget can be resised properly on Dt4. Who knows, how to solve this problem?
My code is:
Q3VBox* vb = new Q3VBox( this);
vb->setFrameStyle( QFrame::StyledPanel | QFrame::Sunken );
myView = new View(vb);
..............
View::View(QWidget* parent) : QGLWidget( parent)
{
int windowHandle = (int) winId();
short hi, lo;
lo = (short) windowHandle;
hi = (short) (windowHandle >> 16);
Handle(WNT_Window) hWnd = new WNT_Window(Handle(Graphic3d_WNTGraphicDevice)::DownCast(myContext->CurrentViewer()->Device()),(int) hi,(int) lo);
myView->SetWindow( hWnd );
..........
}
void View::DrawRectangle(const int MinX, const int MinY, const int MaxX, const int MaxY)
{
QPainter thePainter(this);
thePainter.setPen(Qt::white);
QRect aRect;
aRect.setRect( MinX, MinY, Maxx, Maxy);
thePainter.drawRect(aRect);
}
Fri, 07/14/2006 - 18:43
In Qt3, you probably had a call to setRasterOp(Qt::XorROP) to cause the rectangle to clear and redraw with the mouse movement. This was removed from Qt4 (much to my dismay). You might want to look at the QRubberBand class to achieve a similar, although not as nice, result.
Fri, 07/14/2006 - 20:42
Rob,
Thenk you very much for advise! Could you, please, tell me also, how to use QRubberBand for this case?
Fri, 07/14/2006 - 21:51
Rob,
I understood what is a QRubberBand class, so you don't need to ansver my question. I think, this is a good solution.
Fri, 08/25/2006 - 13:57
Hello,
did you solve your problem?
Could you give me a hint how to programm a simple OCC Viewer with QT4?
Fri, 08/25/2006 - 13:58
Hello,
did you solve your problem?
Could you give me a hint how to programm a simple OCC Viewer with QT4?
Thx!
Markus
Fri, 08/25/2006 - 14:57
Hello, Markus,
Yes, I solve my problems thanks to your advice.
As for OCC viewer on Qt4, I simply took the viewer from Qt3 sample from OCC samples and changed the Qt3 objets to Gt4 support objects. To do that you only need to change the Class names to Qt3 support class names. For example QAction -> Q3Action and so on. May be you need to change something else, but now I forgot what exactly.
Fri, 08/25/2006 - 15:57
Ok, that's one possibility that i haven't think about. But is it possible to take advantage of the QT4 expansions and new classes? I mean, can i mix up Qt3 support classes and the new Qt4 classes?
Thanks!
Markus
Fri, 08/25/2006 - 16:49
Yes, you can use Qt3 support classes and the new Qt4 classes in the same code. You can also redesign the all classes at the Qt3 viewer to Qt4, but it would be more difficult, then to simply use Qt3 support classes.
Wed, 08/30/2006 - 17:28
Hello,
my project now compiles with the qt3 support classes. But when i try to start it comes to an "segmentation fault" - have you maybe an example qt4-app or something?
Wed, 08/30/2006 - 18:11
No, I had not such problems.
Wed, 08/30/2006 - 18:49
Unfortunatelly I have not a simple examle of Qt4 application with OCC viewer, only a big commercial application.
Wed, 08/30/2006 - 23:59
Debugging could help. ;-)
Have a look what statement causes the segmentation fault with a debugger and check out the values of all used variables at this point.
Tue, 10/17/2006 - 16:01
Markus,
I don't know if your still moitoring this thread. I've now worked out the minimal need for a purely Qt4 based viewer - with minimal flicker on resize but I still think its running 2 paint events for each resize event. I've attempted to isolate the specific functionality of the viewer in a specific widget, delegating all the context construction to a widget test harness for now. And QRubberBand is working well in this widget for boxing group selections so long as you set setAutoFillBackgound(false) in the constructor plus aWNTWindow->SetFlags(WDF_NOERASEBKGRND) when the OCC view window is created.
Pete
Tue, 10/17/2006 - 16:04
Markus,
I don't know if your still moitoring this thread. I've now worked out the minimal need for a purely Qt4 based viewer - with minimal flicker on resize but I still think its running 2 paint events for each resize event. I've attempted to isolate the specific functionality of the viewer in a specific widget, delegating all the context construction to a widget test harness for now. And QRubberBand is working well in this widget for boxing group selections so long as you set setAutoFillBackgound(false) in the constructor plus aWNTWindow->SetFlags(WDF_NOERASEBKGRND) when the OCC view window is created.
Pete