[Qt-interest] can I emit signals between windows?
franki
franki at franki.eu.org
Fri Jan 8 17:03:28 CET 2010
Hi,
I have application with main window, which presents some data and when user
clicks button, new window is opened with more detailed information about
record that user clicked.
The problem is, that I can't emit signal from function in this second class
(that hold more detailed window) to this first class which holds my main
window. What I'm doing wrong? dumpObjectInfo, also doesn't show this signal
to be connected to slot in first class.
Here is a piece of example:
first class cpp:
void StackedWidget::startCustPanel(const QModelIndex &index) {
custPanelWidget=new custPanel_TabWidget(key,itsql);
connect(custPanelWidget,SIGNAL(deleteFromMapSig()),this,SLOT(deleteFromMap()));
custPanelWidget->show();
}
void StackedWidget::deleteFromMap() {
qDebug() << "deleteFromMap started";
}
first class header:
class StackedWidget : public QStackedWidget
{
Q_OBJECT
public:
StackedWidget(QWidget *parent = 0,MainWindow* b = 0);
// other variables
custPanel_TabWidget *custPanelWidget;
public slots:
//other slots
void deleteFromMap();
private:
Ui::StackedWidget sw;
second class header:
#ifndef CUSTPANEL_H
#define CUSTPANEL_H
#include "ui_custpanel.h"
#include "itsql.h"
#include <QObject>
#include <QTabWidget>
class StackedWidget;
class custPanel_TabWidget: public QTabWidget
{
Q_OBJECT
public:
custPanel_TabWidget (QVariant c_id,ItSql *it);
~custPanel_TabWidget();
public slots:
void getCustData();
signals:
void deleteFromMapSig();
private:
Ui::custPanel_TabWidget cp;
ItSql *itsql;
QVariant cust_id;
};
#endif
second class cpp:
#include <QtGui>
#include "custpanel.h"
custPanel_TabWidget::custPanel_TabWidget(QVariant c_id,ItSql *it) :
QTabWidget()
{
cp.setupUi(this);
emit deleteFromMapSig();
this->dumpObjectInfo();
}
and output from dumpObjectInfo:
OBJECT custPanel_TabWidget::custPanel_TabWidget
SIGNALS OUT
<None>
SIGNALS IN
<-- QStackedWidget::qt_tabwidget_stackedwidget widgetRemoved(int)
<-- QTabBar::qt_tabwidget_tabbar currentChanged(int)
<-- QTabBar::qt_tabwidget_tabbar tabMoved(int,int)
Thanks in advance.
Marek
More information about the Qt-interest-old
mailing list