July 26, 2011

theblizzfreak theblizzfreak
Lab Rat
50 posts

[merged] qglwidget and layouts problem?

Page  
1

hello i have my QGLWidget setup and showing inside my mainlayout but i cant seem to get it showing a black box or anything like for instance when i dont put QGLWidget inside a layout and just show it, it shows a Black Box like it should but how do i get that within the layout and if i could do this i would be able to use it as a form of eye candy :) thanks in advance

17 replies

July 26, 2011

ZapB ZapB
Robot Herder
1354 posts

Remember to set the layout on the parent widget (e.g. the QMainWindow).

 Signature 

Nokia Certified Qt Specialist
Interested in hearing about Qt related work

July 26, 2011

theblizzfreak theblizzfreak
Lab Rat
50 posts

can you show me an example of that? :) i have no idea lol

sorry for that

heres my guess :) i set qwidget thats parented which i called MainFrame which is the ‘id’ then add the method to it which is setlayout on qmainwindow?

can someone say if thats right or not

July 26, 2011

ZapB ZapB
Robot Herder
1354 posts

Yes that is right for a general QWidget parent. If you are using QMainWindow then you can just do:

  1. mainWindow->setCentralWidget( myGLWidget );

 Signature 

Nokia Certified Qt Specialist
Interested in hearing about Qt related work

July 26, 2011

theblizzfreak theblizzfreak
Lab Rat
50 posts

awesome so how do i add opengl code to it :)

god wish the qt book explained it for the newer versions of QT ;l

July 26, 2011

ZapB ZapB
Robot Herder
1354 posts

Get an svn checkout of a few simple OpenGL examples that uses QGLWidget from my repository:

  1. svn co https://svn.theharmers.co.uk/svn/codes/public/opengl/trunk opengl-examples
  2. cd opengl-examples/06-solar-system
  3. qmake
  4. make

Basically follow the QGLWidget documentation and override paintGL(), resizeGL(), and initializeGL(). Then override any event handler functions that you need e.g. keyPressEvent( QKeyEvent* e ).

 Signature 

Nokia Certified Qt Specialist
Interested in hearing about Qt related work

July 26, 2011

theblizzfreak theblizzfreak
Lab Rat
50 posts

these are great for someone who is using C++ as the core code but i much prefer QML way of doing things so how would one do that with QML? :) i just love that hole idea that a gui is run by a unique part and 3D graphics done by another and plus its alot nicer to work with once im very good with QML i will defently look into C++ focused QT for more control if needed for more freedom as i love C++ :) its very nice

July 26, 2011

theblizzfreak theblizzfreak
Lab Rat
50 posts

?? :)

July 26, 2011

theblizzfreak theblizzfreak
Lab Rat
50 posts

okay so i really didn’t want to post again but im very confused :(

iv got a QML written Application all done by me but i dont understand how to put opengl code into it i have my QGLWidget showing but i dont know where to put the code i know the docuementation is great but only for C++ focused coding and not QML :( so where would one go for QML i like QML but i also like the C++ way of doing it just makes things alot more funner for me using QML any ideas? :) thank you if iv miss read something or iv done something wrong please tell me so its possible that i can learn from it also please tell me how you figure this stuff out because im out of options when it comes to thinking of ways of making things work in QT

July 26, 2011

mlong mlong
Mad Scientist
1517 posts

Please don’t double post. You’ve already asked this question in your original thread [developer.qt.nokia.com] less than two hours ago. Be patient, and someone will reply there if they have an answer for you.

 Signature 

Senior Software Engineer
AccuWeather Enterprise Solutions
/* My views and opinions do not necessarily reflect those of my employer.  Void where prohibited. */

July 26, 2011

xcoder xcoder
Lab Rat
45 posts

Once I came across a code snippet where QGLWidget was embbedded in QML. I think he used somekind of QGraphicsRectangle.

I’ll try to look up the code.

 Signature 

Only a biker knows why a dog sticks his head out of a car window.

July 26, 2011

xcoder xcoder
Lab Rat
45 posts

Take a look at this, but this isn’t the code I found earlier.
But still might be helpful: Click here [talk.maemo.org]

 Signature 

Only a biker knows why a dog sticks his head out of a car window.

July 26, 2011

theblizzfreak theblizzfreak
Lab Rat
50 posts

Thats how you do it with C++ :) i want to do it in QML mostly unless that the only way, if i do then ill otherwise have to rewrite all my QML into C++ / QT way of doing code which is very tedious and i would rather do that in a later update of my application for now i just want things to work and the tutorials to actually work logically :D this is really annoying :((( not at you tho dude just in general finding a decent gui toolkit that has documentation that makes sense is very hard to come by some of the books are nice but they dont explain Opengl with QT in total detail which is very very /inraging :(

July 26, 2011

mlong mlong
Mad Scientist
1517 posts

Ok… maybe we’ll discuss it here. :-)

Outside of some nifty stuff which is still forthcoming, there is no direct OpenGL access available from inside of QML. It all has to be done from the C++ side of things as far as I know. QGLWidget is, by definition, a C++ thing.

The info that xcoder posted is all about making the QGLWidget coexist with your QDeclarative (QML) display area. That’s probably as close as you’re going to get at the moment. I don’t see where that necessarily requires you to rewrite all of your QML into C++.

 Signature 

Senior Software Engineer
AccuWeather Enterprise Solutions
/* My views and opinions do not necessarily reflect those of my employer.  Void where prohibited. */

July 26, 2011

theblizzfreak theblizzfreak
Lab Rat
50 posts

okay :D then ill do it np :) i just need to know where to place the code and is there any tutorials that explains in good detail i tried using the Orginal QT documentation but its not very detailed with the idea of placement of code inside someone elses abstract code and problems of that nature :)

wheres the common place to put this code? :) for most people and why? and how do you figure that out and know the reasons?

please go into detail when answering :]

if you need my code just ask :)

July 26, 2011

Eddy Eddy
Area 51 Engineer
1296 posts

Merged the 2 posts

 Signature 

Qt Certified Specialist
Qt Ambassador

Page  
1

  ‹‹ [SOLVED]Behaviour of QMultiMap      Run executes 4 terminals ››

You must log in to post a reply. Not a member yet? Register here!