Home > Mobile >  Qt two classes signal slot connection
Qt two classes signal slot connection

Time:09-18

I want to a kind of signal in the two classes, another kind of received signal, loading pictures, specific code is as follows:
# # ifndef SKINCHANGE_H
# define SKINCHANGE_H

#include
# include "ui_skinchange. H"
#include
The class SysManten;
The class SkinChange: public QWidget
{
Q_OBJECT

Public:
SkinChange (QWidget * parent=0);
~ SkinChange ();

Signals:
Void changeSkin ();
Private:
Ui: : SkinChange Ui;
};
# endif//SKINCHANGE_H

# include "skinchange. H"
SkinChange: : SkinChange (QWidget * parent)
: QWidget (parent)
{
UI. SetupUi (this);
Connect (UI) pushButton_2, SIGNAL (clicked ()), and this, SLOT (useSkin ()));
}
SkinChange: : ~ SkinChange ()
{

}
Void SkinChange: : useSkin ()
{
Emit changeSkin ();
}


Another class
# # ifndef SYSMANTEN_H
# define SYSMANTEN_H

#include
# include "ui_sysmanten. H"
#include
The class SysManten: public QWidget
{
Q_OBJECT

Public:
SysManten (QWidget * parent=0);
~ SysManten ();
Public slots:
Void showskinInface ();
Void change ();
Private:
Ui: : SysManten Ui;
SkinChange * a;
};
# endif//SYSMANTEN_H

# include "sysmanten. H"
SysManten: : SysManten (QWidget * parent)
: QWidget (parent)
{
UI. SetupUi (this);
A=new SkinChange ();
Connect (a, SIGNAL (changeSkin ()), and this, SLOT (change ()));
}

SysManten: : ~ SysManten ()
{

}
Void SysManten: : change () {
UI. Label - & gt; SetStyleSheet (" border - image: url (:/images/Debug/skin/1 _big. PNG) ");
}
Slot function called compilation can pass, but why can't it, thank you all for the great god give directions

CodePudding user response:

http://blog.csdn.net/zbw1185/article/details/48519371

CodePudding user response:

You link to place a breakpoint into positive returns false, link failure, how can trigger the groove function?

CodePudding user response:

How did you do two class header file contains each other

CodePudding user response:

I wonder how your compiled through, your class SkinChange didn't define a named useSkin slot function
  •  Tags:  
  • Qt
  • Related