Thanks Joh ill try the above mentioned when i get back from work
speaking of which, i tried to run the qq26-openglcanvas program on an Ubuntu 10.04 PC with Qt 4.6.2 and this code runs fine. howcome?
BTW my home PC is Windows 7 using Qt 4.7.0
Thanks Joh ill try the above mentioned when i get back from work
speaking of which, i tried to run the qq26-openglcanvas program on an Ubuntu 10.04 PC with Qt 4.6.2 and this code runs fine. howcome?
BTW my home PC is Windows 7 using Qt 4.7.0
I guess your Ubuntu only supports/has drivers for OpenGL 1.0.
Happy coding
crazymonkey (18th September 2010)
Thanks Joh, youve helped alot!
quick question: where do i make my usual updateGL() , resizeGL() and paintGL() calls then?
Last edited by crazymonkey; 18th September 2010 at 13:02.
You don't!
paintGL => drawBackground
or if you want individual items, subclass QGraphicsItem implement boundingRect and paintEvent (using either QPainter stuff or native OpenGL calls with QPainter.beginNativePainting() .. )
http://www.qtcentre.org/threads/34148-Qt-and-OpenGl-(I-m-lost)?p=158675#post158675
resizeGL => taken care of the view, otherwise subclass QGraphicsView, implement resizeEvent.
updateGL => not necessary.
Joh
and if i want to use listeners to zoom in/out of my openGL scene is it done in the same way as i would normally do it?
Yes. You can then update the view either manually (view->update()), when something changes - or periodically with a Timer (fixed framerate), depends.
Or you split your scene and implement different QGraphicsItems. Call their update() function to trigger a redraw of them.
Joh
Sorry and what about initializeGL() ??
im very noob sorry for all these questions!![]()
Last edited by crazymonkey; 19th September 2010 at 11:13.
InitializeGL. Bit tricky that one.
Your example http://doc.trolltech.com/qq/qq26-openglcanvas.html doesn't use any opengl initialization. Does it on every repaint.
drawBackground is called every 20ms due to (view.setViewportUpdateMode(QGraphicsView::FullVie wportUpdate); in main.cpp and QTimer::singleShot(20, this, SLOT(update())); at the end of drawBackground)
If that's too expensive for you, because you need to setup big displaylists or something like that, you could:
1) Do one of these: http://stackoverflow.com/questions/1...stom-qglwidget
2) Have a look at the boxes demo: http://doc.trolltech.com/latest/demos-boxes.html
3) "Dirty", but efficient Hack:
JohQt Code:
class OpenGLScene : .. { private: bool initialized; } OpenGLScene::OpenGLScene(..) { initialized = false; } { if (initialized == false) { // your initialization goes here.. initialized = true; } }To copy to clipboard, switch view to plain text mode
Last edited by JohannesMunk; 19th September 2010 at 12:47.
hello Joh im having difficulty in adding new widgets
i think this is more of a Qt specific question but what command can i use to set the position of my widgets on my scene?
i have added widgets made via Qt designer perfectly fine. but now i want to make them movable with mouse dragging.
also my widget doesn't have a title like in the example shown http://doc.trolltech.com/qq/qq26-openglcanvas.html
how do i make them movable via mouse dragging and how do i show a title (eg "Instructions")
Hi!
You could have looked it up in the example you referred to!
Cheers!Qt Code:
w->setGeometry(0,0,150,150); w->setWindowTitle("Title"); QGraphicsProxyWidget* proxy = scene->addWidget(w); proxy->setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint); proxy->setPos(10,10);To copy to clipboard, switch view to plain text mode
Joh
sorry i meant how do make it draggable across the scene?
you can take it and drag it around this way. what else do you want?
Bookmarks