I am using Qt5 on Windows 7.
In my current app I have the following piece of code that changes the background color of some push-buttons:   
...
for(int i = 0; i < layout()->count(); i++)
{
    QPushButton * button = static_cast<QPushButton*>(layout()->itemAt(i)->widget());
    button->setStyleSheet(backgroundColor);
}
Well, I have 2 questions about the above code (1st important, 2nd not so important, if you can bear with me...):
1) Is it ok/correct to use static_cast or should I use some other type of casting?    
2) Is it possible to use foreach instead of the for loop above?   
Thanks in advance for your precious time and patience :)
Aucun commentaire:
Enregistrer un commentaire