Close button pressed signal in the QDockWidget

  • How can get pointer to close button in the QDockWidget or get simular signal
    I need only pressed signal, not signal of the close or change of visible
    In advanced thank you for your help!

  • What do you want to achieve?

  • !!
    I have QTabWidget, some widgets in this tabs, and QDockWidget in the QMainWindow. I want to unite QDockWidget with some of QWidget, and because of QMainWindow cant consist of QDockWidget, i need to have QDockWidget in the main window, but i need to QDockWidget be visible only when needed tab is active and if this QDockWidget dont closed by user
    I managed with 1 part(QDockWidget in the active tab), and i want to do 2 part(dont visible QDockWidget if user want it)

  • "QMainWindow::removeDockWidget": is not good ?

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

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

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

  • Thank you for your help!
    It is worked!

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

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

  • 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?

  • My current code:

    #include "QDockWidget"

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

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

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

    connect(parent, SIGNAL(activityChanged(bool)), this ,SLOT(setVisible(bool)));
    connect(this, SIGNAL(visibilityChanged(bool)), this, SLOT(checkedToVisible(bool)));

    void RMathDockWidget::setVisible(bool b)
    //qDebug() << b << "!" << localVisible;
    if (b && localVisible)
    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;
    isParentWidgetVisible = false;
    if (isParentWidgetVisible)
    localVisible = is;

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

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

  • Why you do not use "QAction::toggled": signal ?
    QAction dockWidgetAction = yourDockWidget->toggleViewAction();
    QObject::connect(dockWidgetAction, SIGNAL(toogled(bool)), yourClassPointer, SLOT(dockWidgetToogled(bool))

  • 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?

  • 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]

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

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.