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. Close button pressed signal in the QDockWidget
Forum Updated to NodeBB v4.3 + New Features

Close button pressed signal in the QDockWidget

Scheduled Pinned Locked Moved General and Desktop
17 Posts 3 Posters 14.4k 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.
  • C Offline
    C Offline
    cincirin
    wrote on last edited by
    #4

    "QMainWindow::removeDockWidget":http://doc.qt.nokia.com/stable/qmainwindow.html#removeDockWidget is not good ?

    bq. Removes the dockwidget from the main window layout and hides it. Note that the dockwidget is not deleted.

    1 Reply Last reply
    0
    • R Offline
      R Offline
      Ruzik
      wrote on last edited by
      #5

      No, i dont remove QDockWidgte at all, i need to control changing of visible

      1 Reply Last reply
      0
      • C Offline
        C Offline
        cincirin
        wrote on last edited by
        #6

        Try something like this:
        @
        QAction dockWidgetAction = yourDockWidget->toggleViewAction();
        dockWidgetAction->toogle();
        @

        1 Reply Last reply
        0
        • R Offline
          R Offline
          Ruzik
          wrote on last edited by
          #7

          Thank you for your help!
          It is worked!

          1 Reply Last reply
          0
          • C Offline
            C Offline
            cincirin
            wrote on last edited by
            #8

            You are welcome.
            btw. nice virtual keyboard :-)

            1 Reply Last reply
            0
            • R Offline
              R Offline
              Ruzik
              wrote on last edited by
              #9

              If this is an allusion to agglomerate interface, it will be configured :-)

              1 Reply Last reply
              0
              • R Offline
                R Offline
                Ruzik
                wrote on last edited by
                #10

                I have one problem:
                If user want to moved QDockWidget from QMainWindow to separate window: at first, widget become invisible and then redrawn as separate window
                But how will I know when it is redrawn, and when the user closes it, if I get the same signals?

                1 Reply Last reply
                0
                • R Offline
                  R Offline
                  Ruzik
                  wrote on last edited by
                  #11

                  My current code:
                  RMathDockWidget.h
                  @#ifndef RMATHDOCKWIDGET
                  #define RMATHDOCKWIDGET

                  #include "QDockWidget"

                  class RMathDockWidget : public QDockWidget
                  {
                  Q_OBJECT
                  public:
                  RMathDockWidget(QWidget *parent = 0, Qt::WFlags flags=0);
                  ~RMathDockWidget();
                  private:
                  bool localVisible;

                  QWidget * parentWidget;
                  public slots:
                  void setVisible(bool);
                  protected slots:
                  void checkedToVisible(bool);
                  };
                  #endif@
                  RMathDockWidget.cpp
                  @#include "RMathDockWidget.h"
                  #include "QDebug"
                  #include "QAction"
                  #include "Geter/Geter.h"

                  RMathDockWidget::RMathDockWidget(QWidget *parent, Qt::WFlags flags) : QDockWidget(parent,flags)
                  {
                  localVisible = true;
                  if(!parent)
                  {
                  qDebug() << "[Rizek message]Empty parent of RMathDockWidget!";
                  }
                  else
                  parentWidget = parent;

                  this->setMinimumWidth(120);
                  connect(parent, SIGNAL(activityChanged(bool)), this ,SLOT(setVisible(bool)));
                  connect(this, SIGNAL(visibilityChanged(bool)), this, SLOT(checkedToVisible(bool)));
                  this->setVisible(false);
                  }
                  RMathDockWidget::~RMathDockWidget()
                  {

                  }
                  void RMathDockWidget::setVisible(bool b)
                  {
                  //qDebug() << b << "!" << localVisible;
                  if (b && localVisible)
                  QDockWidget::setVisible(true);
                  else
                  QDockWidget::setVisible(false);
                  }
                  void RMathDockWidget::checkedToVisible(bool is)
                  {
                  qDebug() << is;
                  Geter g; //object for getting parent Window class
                  bool isParentWidgetVisible;
                  if(g.getRizekMath()->getTabWidget()->currentWidget() == parentWidget) //is current tab of tabWidget is active
                  isParentWidgetVisible = true;
                  else
                  isParentWidgetVisible = false;
                  if (isParentWidgetVisible)
                  localVisible = is;
                  }@

                  1 Reply Last reply
                  0
                  • R Offline
                    R Offline
                    Ruzik
                    wrote on last edited by
                    #12

                    Exactly, are there no any ways to get signal from QDockWidget/Close Button when user click to this button?

                    1 Reply Last reply
                    0
                    • R Offline
                      R Offline
                      Ruzik
                      wrote on last edited by
                      #13

                      Maybe, somehow we can determine when the widget becomes invisible due to the repainting, or when the user wanted it

                      1 Reply Last reply
                      0
                      • C Offline
                        C Offline
                        cincirin
                        wrote on last edited by
                        #14

                        Why you do not use "QAction::toggled":http://doc.qt.nokia.com/latest/qaction.html#toggled signal ?
                        @
                        QAction dockWidgetAction = yourDockWidget->toggleViewAction();
                        QObject::connect(dockWidgetAction, SIGNAL(toogled(bool)), yourClassPointer, SLOT(dockWidgetToogled(bool))
                        @

                        1 Reply Last reply
                        0
                        • R Offline
                          R Offline
                          Ruzik
                          wrote on last edited by
                          #15

                          Because, signal void QDockWidget::visibilityChanged ( bool visible ) simular it, and i use this signal
                          If i write it
                          @connect(this, SIGNAL(visibilityChanged(bool)), this, SLOT(checkedToVisible(bool)));@
                          instead of
                          @connect(dockWidgetAction, SIGNAL(toogled(bool)), yourClassPointer, SLOT(dockWidgetToogled(bool))@
                          There are no to change or i dont right?

                          1 Reply Last reply
                          0
                          • C Offline
                            C Offline
                            cincirin
                            wrote on last edited by
                            #16

                            QDockWidget::visibilityChanged is fired

                            bq. as well as when it is docked in a tabbed dock area and its tab becomes selected or unselected.

                            I answered to
                            [quote author="Ruzik" date="1320432125"]Exactly, are there no any ways to get signal from QDockWidget/Close Button when user click to this button?[/quote]

                            1 Reply Last reply
                            0
                            • R Offline
                              R Offline
                              Ruzik
                              wrote on last edited by
                              #17

                              It was my mistake - override setVisible()
                              Once again thank you for your help!

                              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