Quote:Original post by SeaBourne
What do you mean you cannot add it to the layout? Code looks fine. Btw if you have a parameter in the constructor you have to pass it to the base constructor. You passing 0 is not correct. Because if you was to pass this to that parameter it would cause a memleak. Due to you not deleting the Window since passing "this" would cause the Window to be correctly deleted.
Also you do not need to pass "this" to the ctor of the QD3DWidget since it's being added to a layout. As the layout takes ownership of the widget.
Sorry, we did not know of these errors on Qt (I'm new in programming with Qt) :)
As the window, I am creating in QtDesigner:
Using the ui, the code looks like, and the window when run like this:
Window::Window(QWidget* parent) : QWidget(parent){ ui.setupUi(this); ui.horizontalLayout->addWidget(new QD3DWidget());}
And when I create my QHBoxLayout the code looks like this:
Window::Window(QWidget* parent) : QWidget(parent){ ui.setupUi(this); QHBoxLayout *layout = new QHBoxLayout(); setLayout(layout); layout->addWidget(new QD3DWidget());}
A note: The blue screen means that the code of DirectX is working, I configured it to clean the screen with the color blue
and using the code (last image), so if I do (wrong):
layout->addWidget(new QD3DWidget()); //not using this
it is white
and if I do so, it turns blue (correct):
layout->addWidget(new QD3DWidget(this)); //using this
Thanks