Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Place a Dock widget programatically

Place a Dock widget programatically

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 2.0k Views 1 Watching
  • 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.
  • G Offline
    G Offline
    GrahamL
    wrote on last edited by
    #1

    Hello
    I need to move the position of a dock widget from within my program after it has been initially created and displayed.
    I tried this
    @
    removeDockWidget(m_jobDetailsDockWidget);
    removeDockWidget(m_eventCriteriaDockWidget);
    addDockWidget(Qt::BottomDockWidgetArea,m_jobDetailsDockWidget);
    addDockWidget(Qt::BottomDockWidgetArea,m_eventCriteriaDockWidget);
    @
    But the dock widgets are removed but not re displayed.

    I have amended my code -
    @
    m_allowDockingAction->setChecked(false);
    removeDockWidget(m_jobDetailsDockWidget);
    removeDockWidget(m_eventCriteriaDockWidget);
    bool bb = m_jobDetailsDockWidget->isFloating();
    m_jobDetailsDockWidget->setFloating(false);
    bb = m_jobDetailsDockWidget->isFloating();
    addDockWidget(Qt::BottomDockWidgetArea,m_jobDetailsDockWidget);
    addDockWidget(Qt::BottomDockWidgetArea,m_eventCriteriaDockWidget);
    m_jobDetailsDockWidget->setFeatures(QDockWidget::NoDockWidgetFeatures);
    m_eventCriteriaDockWidget->setFeatures(QDockWidget::NoDockWidgetFeatures);
    //m_jobDetailsDockWidget->toggleViewAction()->activate(QAction::Trigger);
    m_jobDetailsDockWidget->show();
    m_eventCriteriaDockWidget->show();
    tabifyDockWidget(m_eventCriteriaDockWidget,m_jobDetailsDockWidget);
    @

    This now works as expected UNLESS one of the docked widgets is floating in which case the docked widget remains floating even tho I call setFloating(false)

    How can I overcome this?

    Thanks

    Is there a trick to this?

    Thanks

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      removeDockWidget hides the widget, so a simple setVisible(true) should show it.

      But first thing, why don't you initialize your docks at the right place ? (Since your remove all dock features in your second code snippet)

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved