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?



  • !http://hostingkartinok.com/image/01201110/84f3a2809f59321c77e562c77b76341e.jpg(http://hostingkartinok.com/image/01201110/84f3a2809f59321c77e562c77b76341e.jpg)!
    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":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.



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



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



  • 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:
    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;
    }@



  • 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":http://doc.qt.nokia.com/latest/qaction.html#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.