Sending a Signal to a Slot when a toolbar is Docked or Undocked
-
Hi here I am agin with a simple question but I can no find the answer in the documentation.
Basically my application has a Menu, ToolBar and QSpliter.For the purpose of this explanation let us say the Splitter hold a TextEditor and a tree Explorer
My problem is that I want the splitter to occupy the entire real state of the QMainWindow.For the I adde and Even Handler that that Recalculate the size of the
Spliter when the main window is resized and this works very well.Basicall I take into accoun the size of the Menu and the ToolBar and subtrabt from the main frame child rectangle.
The event funtion is like this
@bool alchemedia::event(QEvent msg)
{
switch (msg->type())
{
case QEvent::Resize:
{
//QResizeEvent resize = (QResizeEvent*) msg;
//QRect rect (frameGeometry());
QRect rect (childrenRect ());
if (m_toolBar) {
int x1;
int y1;
int w1;
int h1;int w = m_toolBar->width(); int h = m_toolBar->height(); QRect toolBarRect (m_toolBar->rect()); rect.getRect(&x1, &y1, &w1, &h1); y1 += h; h1 -= h; rect.setRect(x1, y1, w1, h1);
}
if (m_menubar) {
int x1;
int y1;
int w1;
int h1;int w = m_menubar->width(); int h = m_menubar->height(); QRect toolBarRect (m_toolBar->rect()); rect.getRect(&x1, &y1, &w1, &h1); y1 += h; h1 -= h; rect.setRect(x1, y1, w1, h1);
}
m_canvas->setGeometry(rect);
break;
}}
return QMainWindow::event (msg);
}@However I need an event or call the event function when the ToolBar is undocked
But I can no figure out how to determine if the ToolBar is docked of UndockedI also tried to connect the signal movableChanged to a slot in the main window,
Like this:@// add the tool bars
m_toolBar = new QToolBar(this);
m_toolBar->setObjectName(QString::fromUtf8("editToolBar"));
addToolBar(Qt::TopToolBarArea, m_toolBar);
connect (m_toolBar, SIGNAL (movableChanged(bool)), this, SLOT (ToolBarbChanged()));@
But this does not works either. It does not give me any runtime error but my ToolBarbChanged in not called.
Can some one tell me how can I wire a signal to detrmone when a ToolBar is Undocked? -
Oh Thank you,
I do not want to use the Horizontal of Vertical Lay Out because I have to add more Panes, and a simple box layout manager is very limiting.
Basically my application will have more floating/docking, a render Canvas, a Text Window, and Command Panel and maybe some others.
In MFC this is controlled automatically by a Docking Manager, but QT does not seems to have anything like that, on the other hand QT is much easier to use and more importantly it is cross platform.Any way adding the QHBoxLayout did not fix the problem, but I realized that my mistake was that I did not call function setCentralWidget(m_canvas);
Here is the code@// create all menu and toolbars
CreateMenus();// create the main render Canvas
m_canvas = new alchemediaCanvas (this);
//QHBoxLayout* horizontalLayout = new QHBoxLayout(m_canvas);
//horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout"));
setCentralWidget(m_canvas);@
and now is works even without the QHBoxLayoutLater I may have to craet my won LayOut Manage to emulate the MFC docking Manager, but so far this si very good.
Thank you. -
Oh I am sure Qt can do it, I am not sure I know enough to figure out how.
It is out of topic but sine you mention it, I was think how to go about that the lay out thingFor example I played with docking in designer before I started coding and I could not figured out how to set something that behaves like for example Visual Studio, or 3D studio max front end.
Maybe it is because I am not experience enough, but in any case I am not there yet.
I hope that by that time I am fluent enough to get some that behave similar.
For now I have plenty to work on.Thank for the help
-
ignore this please