Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    QDockWidget allowed areas in QMainWindow

    General and Desktop
    2
    10
    8717
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • J
      jpalbertini last edited by

      Hi everyone (and sorry for my bad english),

      I have a MainWindow (allow nested, allow tabbed) with 3 DockWidgets created with the designer. The first one that can only be floating or docked on the left, another one which can only be floating or docked on the bottom, and the third can only be dock on top or right and not floating.

      My problem is that at runtime I add tabwidgets on the third one, which works great, but even if I set its allowed areas not to dock on left or bottom, i can "tab" them to the left and bottom with the two others created with the designer.

      Anybody had encounter this problem already ?

      Thanks for your reply :)

      [EDIT] I catch the signal dockLocationChanged with slot in my main window and everywhere I dock the widget, the new area is always the Top...

      1 Reply Last reply Reply Quote 0
      • J
        jpalbertini last edited by

        Anyone ?? :(

        1 Reply Last reply Reply Quote 0
        • G
          goblincoding last edited by

          Hi there,

          First of all, your English is perfectly understandable, so don't worry about that :)

          Your problem, however, not so much :D

          I don't quite understand what you mean with the following:

          [quote author="jpalbertini" date="1359113800"]
          My problem is that at runtime I add tabwidgets on the third one, which works great, but even if I set its allowed areas not to dock on left or bottom, i can "tab" them to the left and bottom with the two others created with the designer[/quote]

          Do you create the third dock widget dynamically, or do you only set its contents? Also, I am not sure what you mean with "tab" them to the left or bottom.

          It would be very cool if you could provide a minimal example of your code.

          http://www.goblincoding.com

          1 Reply Last reply Reply Quote 0
          • J
            jpalbertini last edited by

            Thanks for your reply :)

            The third dock widget is created with the designer.

            When I say that I tab them, I mean that I add them to my main window, and then I "tabify" them with my third widget (dockMainWidget), which act like an anchor...

            Note that in the folowing code, the TabWidget is a class heriting from QDockWidget (which can be prety confusing)

            @void MainWindow::addTab(TabWidget * page)
            {
            page->setFocusPolicy(Qt::StrongFocus);
            page->setAllowedAreas(Qt::RightDockWidgetArea | Qt::TopDockWidgetArea);

            this->addDockWidget(Qt::RightDockWidgetArea, page);

            this->tabifyDockWidget(dockMainWidget, page);
            this->setTabOrder(page, dockMainWidget);

            page->setVisible(true);
            page->setFocus();
            page->raise();

            connect(page,SIGNAL(changed(TabWidget )),this,SLOT(tabWidgetChanged(TabWidget)));
            connect(page, SIGNAL(closed(QString)), this, SLOT(closeTab(QString)));

            mTabWidgets.insert(page->key(), page);
            actionClose_current_tab->setEnabled(true);
            page->setAllowedAreas(Qt::RightDockWidgetArea | Qt::TopDockWidgetArea);

            connect(page, SIGNAL(dockLocationChanged(Qt::DockWidgetArea)), this, SLOT(dockLocChanged(Qt::DockWidgetArea)));
            }@

            1 Reply Last reply Reply Quote 0
            • G
              goblincoding last edited by

              I'm sorry, but there are too many variables falling outside of the scope of what you provided for me to figure out what is happening and where it is going wrong (the only noticable error is that you call setAllowedAreas() twice, but you call it with the same parameters each time so although unnecessary, it shouldn't have any effect or bearing on your problem).

              To be honest, I still don't fully understand what you are trying to achieve either. Are you trying to add dockwidgets as tabs to a tab widget? So that you can undock each tab independent of the others?

              http://www.goblincoding.com

              1 Reply Last reply Reply Quote 0
              • J
                jpalbertini last edited by

                Yes that's exactly what I am trying to do, add dock widgets as tabs to a staticaly defined dock widget so I dock and undock them individually.

                My problem is that when I add a dockwidget it can be docked everywhere and not only at Right or Top.

                The thing is everytime I go to the slot dockLocChanged of the main window, the value of the "area" parameter that I receive from the signal is always 4, which is the value of TopWidgetArea, even if I dock the dock widget with a dock widget which is in LeftWidgetArea

                The setAllowedAreas is called twice, just to make sure :)

                code of the slot:

                @void MainWindow::dockLocChanged(Qt::DockWidgetArea area)
                {
                qDebug() << "widget area changed " << (static_cast<TabWidget*>(sender()))-> title() << " to area: " << area;
                qDebug() << "widget allowed areas: " << (static_cast<TabWidget*>(sender()))->allowedAreas();

                   qDebug() << "info allowed area  " << dockInfoWidget->allowedAreas() << " , docked: " << !dockInfoWidget->isFloating();
                   qDebug() << "tree allowed area  " << dockTreeViewWidget->allowedAreas() << " , docked: " << !dockTreeViewWidget->isFloating();
                   qDebug() << "main view allowed area  " << dockMainWidget->allowedAreas() << " , docked: " << !dockMainWidget->isFloating();
                

                }@

                1 Reply Last reply Reply Quote 0
                • G
                  goblincoding last edited by

                  Any chance that you could provide a minimal, compilable version of your application?

                  http://www.goblincoding.com

                  1 Reply Last reply Reply Quote 0
                  • J
                    jpalbertini last edited by

                    no sorry can't do that...

                    1 Reply Last reply Reply Quote 0
                    • G
                      goblincoding last edited by

                      Ok, I haven't actually tried this example, but at first glance it seems relevant and perhaps it can help:

                      "Qt Main Window Demo":http://doc.qt.digia.com/4.7/demos-mainwindow.html

                      Good luck! :)

                      http://www.goblincoding.com

                      1 Reply Last reply Reply Quote 0
                      • J
                        jpalbertini last edited by

                        Thanks, i found the problem:

                        The central widget of my main window was invisible under the widget docked in bottom, so all the docks where on top of the central widgets, therefore they can be dockable everywhere....

                        I am now trying to modify the central widget so its height would be equal to 0 but even by settings its maximum size, it can shrink to 0 manually but it is not shrink at startup and it can take every size possible...

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post