Yea, i call QDockWidget::setWidget() and calling resize(300, 300) creates the display, but it does not expand vertically filling the widget. It does fill it in horizontally. I have three dock widgets, all set at the top, and when i close one of the non scene dock window, the scene dock window expands horizontally to fill the area. However, if i close the dock window that is docked on the bottom, the scene window does not fill in that additional area.
Also, if i only use the scene dock window, no other dock windows, it is has the same outcome.
Editor.cpp
void Editor::CreateSceneDockWindow() {
sceneWindow_ = new EditorSceneWindow(context_, "Scene", this);
sceneWindow_->Create(engine_);
addDockWidget(Qt::TopDockWidgetArea, sceneWindow_);
}
void Editor::CreateSceneDockWindow() {
sceneWindow_ = new EditorSceneWindow(context_, "Scene", this);
sceneWindow_->Create(engine_);
addDockWidget(Qt::TopDockWidgetArea, sceneWindow_);
}
To copy to clipboard, switch view to plain text mode
EditorSceneWindow.cpp
EditorSceneWindow
::EditorSceneWindow(Context
* context,
QString title,
QWidget* parent
) : EditorWindow(context, title, parent),
d3dRendererWidget_(0) {
}
EditorSceneWindow::~EditorSceneWindow() {
}
void EditorSceneWindow::Create(WeakPtr<Engine> engine) {
engine_ = engine;
d3dRendererWidget_ = new D3DRenderWidget(this, engine_);
layout->addWidget(d3dRendererWidget_);
container->setLayout(layout);
setWidget(container);
}
EditorSceneWindow::EditorSceneWindow(Context* context, QString title, QWidget* parent) :
EditorWindow(context, title, parent),
d3dRendererWidget_(0) {
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
}
EditorSceneWindow::~EditorSceneWindow() {
}
void EditorSceneWindow::Create(WeakPtr<Engine> engine) {
engine_ = engine;
QWidget* container = new QWidget(this);
container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
QVBoxLayout* layout = new QVBoxLayout(this);
d3dRendererWidget_ = new D3DRenderWidget(this, engine_);
layout->addWidget(d3dRendererWidget_);
container->setLayout(layout);
setWidget(container);
}
To copy to clipboard, switch view to plain text mode
D3DRenderWindow.cpp
D3DRenderWidget
::D3DRenderWidget(QWidget* parent, Engine
* engine
) :
setAttribute(Qt::WA_PaintOnScreen, true);
setAttribute(Qt::WA_NativeWindow, true);
resize(640, 480);
//
engine_ = engine;
// Set our Direct3D widget as the window to render into
Platform* platform = engine_->GetSubsystem<Platform>();
platform->SetExternalWindow(reinterpret_cast<void*>(this->winId()));
// Configure the engine for Editor functionality
VariantMap engineParameters;
engineParameters["Fullscreen"] = false;
connect(timer, SIGNAL(timeout()), this, SLOT(update()));
timer->start(16);
}
D3DRenderWidget::~D3DRenderWidget() {
}
if (!engine_) return;
engine_->RunFrame();
}
int widgetWidth = width();
int widgetHeight= height();
using namespace WindowResized;
VariantMap resizeEventMap;
resizeEventMap[P_WIDTH] = width();
resizeEventMap[P_HEIGHT] = height();
engine_->SendEvent(E_WINDOWRESIZED, resizeEventMap);
}
D3DRenderWidget::D3DRenderWidget(QWidget* parent, Engine* engine) :
QWidget(parent) {
setAttribute(Qt::WA_PaintOnScreen, true);
setAttribute(Qt::WA_NativeWindow, true);
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
resize(640, 480);
//
engine_ = engine;
// Set our Direct3D widget as the window to render into
Platform* platform = engine_->GetSubsystem<Platform>();
platform->SetExternalWindow(reinterpret_cast<void*>(this->winId()));
// Configure the engine for Editor functionality
VariantMap engineParameters;
engineParameters["Fullscreen"] = false;
QTimer* timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(update()));
timer->start(16);
}
D3DRenderWidget::~D3DRenderWidget() {
}
void D3DRenderWidget::paintEvent(QPaintEvent* event) {
if (!engine_) return;
engine_->RunFrame();
}
void D3DRenderWidget::resizeEvent(QResizeEvent* event) {
int widgetWidth = width();
int widgetHeight= height();
using namespace WindowResized;
VariantMap resizeEventMap;
resizeEventMap[P_WIDTH] = width();
resizeEventMap[P_HEIGHT] = height();
engine_->SendEvent(E_WINDOWRESIZED, resizeEventMap);
}
To copy to clipboard, switch view to plain text mode
Added after 21 minutes:
Issue Resolved!!!
Found this article which states that you have to have a central widget, even if nothing is present in it. you can just hide it. one line of code, and BOOM!
placed this inside Editor.cpp constructore, and now it fills in the area as expected.
ui->centralWidget->hide();
ui->centralWidget->hide();
To copy to clipboard, switch view to plain text mode
Thanks much for your help!!!
Note, as i am new on these forums, is there reputation points or anything, if so, i would give you a +1, if not, thanks anyways
Bookmarks