Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-24024

Make QDockWidget method void setWidget(QWidget *widget); virtual

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • Not Evaluated
    • None
    • 4.8.0
    • None
    • MS VisualStudio 2010, SP1
      Qt Add-in 1.1.10
      Qt 4.7.8

    Description

      It would be valuable to have the QDockWidget::setWidget() method virtual.

      Imagine a dockwidget class with autohide/autoshow functionality like you know it from Visual Studio.
      class CHideableDockWidget : public QDockWidget

      This could be achieved e.g. with a QStackedWidget and a QTabBar.
      The Tabbar will be positioned on the first page of the stacked widget,
      and the dockwidgets widget on the second page of the stacked widget.
      Then the StackedWidget has to be set as the DockWidgets widget
      To perform the autohide or autoshow funcitonality then you can simply
      switch the currentIndex of the stackedWidget and change the size of it.

      But this requires to overload the setWidget method.
      Here is one possible implementation:

      void CHideableDockWidget::setWidget(QWidget *widget)
      {
      while (m_stackedWidget.count() > 0)

      { m_stackedWidget.removeWidget(m_stackedWidget.widget(0)); }

      m_stackedWidget.addWidget(&m_tabBar);
      m_stackedWidget.addWidget(widget);
      m_stackedWidget.setCurrentIndex(1);

      if (this->widget() != &m_stackedWidget)

      { QDockWidget::setWidget(&m_stackedWidget); }

      }

      This implementation would work with the current Qt version and
      QDockWidget setWidget method declaration, but we would hide
      the inherited method name and the code would work under certain
      circumstances only.
      (See Scott Meyers, "Effective C++", Item 33 - Avoid hiding inherited names)

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            Unassigned Unassigned
            ibdm Donald Marotzke
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes