JasonKretzer
12th July 2013, 13:32
Using 5.0.2 on Win 7
I have 2 "ImageLoop" classes [which extend QWidget] where each take up half the screen, split vertically. Each contains a QLabel for displaying a list of jpg files. So, inside a for loop, I give each widget their list of images, and emit a "listfull" signal which I have connected to a slot - "playList" - in each of the two widgets. Unfortunately, it appears that only the first widget's signal ever gets emitted as only the first widget is ever updated.
I am new to Qt programming and maybe I am misunderstanding the slot/signal system. I thought the pseudocode below would, for each instance, fill the list, emit the signal, and each instance would go off on their merry way -- basically each widget simultaneously and independently showing images. So, question is what am I missing? Or am I going to have to spawn each of these in their own thread?
Thanks!
Pseudocode
for(int i=0; i<2; i++){
Create ImageLoop instance
connect(instance, SIGNAL(listfull()), instance, SLOT(playList()));
instance->FillList(arrayOfImageFileNames);
}
//inside of ImageLoop class
void FillList(arrayOfImageFileNames) {
//adds all files to an internal list
//when finished
emit listfull();
}
//inside of ImageLoop class
void playList() {
//code to loop through each image and show it
}
I have 2 "ImageLoop" classes [which extend QWidget] where each take up half the screen, split vertically. Each contains a QLabel for displaying a list of jpg files. So, inside a for loop, I give each widget their list of images, and emit a "listfull" signal which I have connected to a slot - "playList" - in each of the two widgets. Unfortunately, it appears that only the first widget's signal ever gets emitted as only the first widget is ever updated.
I am new to Qt programming and maybe I am misunderstanding the slot/signal system. I thought the pseudocode below would, for each instance, fill the list, emit the signal, and each instance would go off on their merry way -- basically each widget simultaneously and independently showing images. So, question is what am I missing? Or am I going to have to spawn each of these in their own thread?
Thanks!
Pseudocode
for(int i=0; i<2; i++){
Create ImageLoop instance
connect(instance, SIGNAL(listfull()), instance, SLOT(playList()));
instance->FillList(arrayOfImageFileNames);
}
//inside of ImageLoop class
void FillList(arrayOfImageFileNames) {
//adds all files to an internal list
//when finished
emit listfull();
}
//inside of ImageLoop class
void playList() {
//code to loop through each image and show it
}