Skip to content

Instantly share code, notes, and snippets.

@cedias
Created March 14, 2013 21:37
Show Gist options
  • Select an option

  • Save cedias/5165495 to your computer and use it in GitHub Desktop.

Select an option

Save cedias/5165495 to your computer and use it in GitHub Desktop.
Qt

#Qt - LI357

##Signal & Slots

Qt s'organise autour du concept de signaux et de slots.

Pour connecter deux entités:

##Connect

QObject::connect(object* source, SIGNAL(hello()), object * cible , SLOT(wave()));

###Creer un Slot

  1. Ajouter signature dans .h
  2. Ajouter définition dans .cpp
//class.h

[...]

public slot:
    wave();

[...]

//class.cpp

[...]

void class::wave(){
 remuerBras();
}

[...]

##Creer un Signal

  1. Ajouter signature dans .h
  2. Ajouter définition dans .cpp
//.h
public signal:
    hello();
//.cpp

void class::hello(){
 if(xyz)
   emit hello();

}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment