Fixed geometry, needs to be relative to root
This commit is contained in:
@@ -113,7 +113,7 @@ void MyMainWindow::createDockWidgets()
|
||||
Q_ASSERT(m_dockwidgets.isEmpty());
|
||||
|
||||
// Create 9 KDDockWidget::DockWidget and the respective widgets they're hosting (MyWidget instances)
|
||||
for (int i = 0; i < 3; i++)
|
||||
for (int i = 0; i < 9; i++)
|
||||
m_dockwidgets << newDockWidget();
|
||||
|
||||
|
||||
@@ -124,10 +124,10 @@ void MyMainWindow::createDockWidgets()
|
||||
addDockWidget(m_dockwidgets[1], KDDockWidgets::Location_OnRight, m_dockwidgets[0]);
|
||||
|
||||
addDockWidget(m_dockwidgets[2], KDDockWidgets::Location_OnLeft);
|
||||
/*addDockWidget(m_dockwidgets[3], KDDockWidgets::Location_OnBottom);
|
||||
addDockWidget(m_dockwidgets[3], KDDockWidgets::Location_OnBottom);
|
||||
addDockWidget(m_dockwidgets[4], KDDockWidgets::Location_OnBottom);
|
||||
|
||||
// Tab two dock widgets toghether
|
||||
// Tab two dock widgets together
|
||||
m_dockwidgets[3]->addDockWidgetAsTab(m_dockwidgets[5]);
|
||||
|
||||
// 6 is floating, as it wasn't added to the main window via MainWindow::addDockWidget().
|
||||
@@ -138,7 +138,7 @@ void MyMainWindow::createDockWidgets()
|
||||
m_dockwidgets[6]->addDockWidgetToContainingWindow(m_dockwidgets[8], KDDockWidgets::Location_OnBottom);
|
||||
|
||||
auto floatingWindow = m_dockwidgets[6]->window();
|
||||
floatingWindow->move(100, 100); */
|
||||
floatingWindow->move(100, 100);
|
||||
}
|
||||
|
||||
KDDockWidgets::DockWidgetBase *MyMainWindow::newDockWidget()
|
||||
|
||||
@@ -31,6 +31,21 @@ ItemContainer *Item::root() const
|
||||
: const_cast<ItemContainer*>(qobject_cast<const ItemContainer*>(this));
|
||||
}
|
||||
|
||||
QRect Item::mapToRoot(QRect r) const
|
||||
{
|
||||
const QPoint topLeft = mapToRoot(r.topLeft());
|
||||
r.moveTopLeft(topLeft);
|
||||
return r;
|
||||
}
|
||||
|
||||
QPoint Item::mapToRoot(QPoint p) const
|
||||
{
|
||||
if (isRoot())
|
||||
return p;
|
||||
|
||||
return p + parentContainer()->pos();
|
||||
}
|
||||
|
||||
void Item::resize(QSize newSize)
|
||||
{
|
||||
setSize(newSize);
|
||||
@@ -303,7 +318,7 @@ void Item::setGeometry(QRect rect)
|
||||
Q_EMIT heightChanged();
|
||||
|
||||
if (m_isVisible && m_widget) {
|
||||
m_widget->setGeometry(m_geometry);
|
||||
m_widget->setGeometry(mapToRoot(m_geometry));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -234,6 +234,8 @@ public:
|
||||
ItemContainer *root() const;
|
||||
void deserialize() {}
|
||||
void serialize() {}
|
||||
QRect mapToRoot(QRect local) const;
|
||||
QPoint mapToRoot(QPoint local) const;
|
||||
|
||||
QWidget *frame() const { return m_widget; } // TODO: rename
|
||||
void setFrame(QWidget *w) { m_widget = w; } // TODO rename
|
||||
|
||||
Reference in New Issue
Block a user