[Qt-interest] can I emit signals between windows?
Sean Harmer
sean.harmer at maps-technology.com
Fri Jan 8 17:14:47 CET 2010
Hi,
I think it is because you are emitting the deleteFromMapSig() signal in the
constructor of the detailed window but this is created *before* you make the
connection - and so the signal just disappears into the ether.
You need to create the object, connect the signal/slot, then emit the signal
later in response to something interesting happening in your detail window.
HTH,
Sean
On Friday 08 January 2010 16:03:28 franki wrote:
> 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
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
More information about the Qt-interest-old
mailing list