felo188
16th August 2011, 16:37
Hi. In my gui i have some buttons. For example when i move a mouse on IRButton1 and next IRButton2 i increase liczbaLudzi1. When i change a direction (from IRButton2 to IRButton1) decrease liczbaLudzi1. I want to display as many pixmaps (using labels) as it's value liczbaLudzi1. A part of program reliable for increase and decrease of liczbaLudzi1 is in filter event and it is working (increasing and decreasing as i wanted). I have problem with painting pixmaps. The problem is that if i increase liczbaLudzi1 i also increase number of pixmaps on gui (it's ok) but when i decrease liczbaLudzi1 the number of pixmaps stays on the last highest value liczbaLudzi1.
void MainWindow::paintEvent(QPaintEvent *paint)
{
...
switch (liczbaLudzi1)
{
case 1:
ludzik1->setVisible(true); update();break;
case 2:
ludzik2->setVisible(true); update();break;
case 3:
ludzik3->setVisible(true); update();break;
}
...
}
Where ludzik_ is QLabel.
What i should do to solve it. I try with update() but switch only works up (increase number of labels with increasing number of liczbaLudzi1) and don't works down (decrease number of labels with decreasing number of liczbaLudzi1).
void MainWindow::paintEvent(QPaintEvent *paint)
{
...
switch (liczbaLudzi1)
{
case 1:
ludzik1->setVisible(true); update();break;
case 2:
ludzik2->setVisible(true); update();break;
case 3:
ludzik3->setVisible(true); update();break;
}
...
}
Where ludzik_ is QLabel.
What i should do to solve it. I try with update() but switch only works up (increase number of labels with increasing number of liczbaLudzi1) and don't works down (decrease number of labels with decreasing number of liczbaLudzi1).