Close button pressed signal in the QDockWidget
-
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!