Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
visinet last edited by
I just started playing with QT in my quest to find a replacement for my Borland C++ Builder and and wanted to do a quick performance test between it, C# and Java in updating a bunch of buttons on a form. Basically I have a form with 200 buttons and a timer. When the timer goes off every 500ms I loop through all the buttons on the form and change the background color between RED and BLUE so they blink every half second. I use and elapsed timer in the Timer event mentioned above to time how long it takes to loop through all the controls and change their background colors. I have done basically the exact same thing in both C# and a Java swing app and the results I am seeing are not what I expected. Visually, the QT app looks the fastest, in that all the buttons change color in sync without any impression of lag, while in the C# and Java apps the buttons appear to be out of sync due to time required to redraw each and every button. This is what I would expect to see from good old C++ vs interpreted language such as c# and java. However, the time that is being reported by the elapsed timer in QT, and equivalent methods in C# and Java are the exact opposite. The QT code is taking about 90ms where both the C# and Java are taking like .5ms. Yes, that is .5ms and not a typo. Not only is that is a massive difference, but I would expect QT to be reporting the faster times, not 100X slower.
Can anyone maybe shed some light on this for me? Am I doing something stupid? Is this a rare case, or should I not be surprised to see similar kinds of results when looking at graphics related stuff like this.
Thanks a bunch for any help on this.
Hi, and welcome to the Qt Dev Net!
I don't know how the C# and Java functions behave, but I'm guessing that they're asynchronous (the functions return before they the colour is fully updated), while the Qt function is synchronous (the function waits until the colour is fully updated before returning).
If my guess is correct, then you're not actually measuring the time taken to update the colours in C# and Java.
By the way, how do you change the colour of the Qt buttons?
visinet last edited by
I was wondering if it was something like that where the call in QT was blocking. Do you know for sure if it is synchronous? What about other window elements? Is anything that operates on windows controls going to be synchronous? If so, I wouldn't think that would be a very ideal implementation. How could you keep a program responsive when a lot of this type of stuff needs to be done? The only way I could find to change the color was to call setStyleSheet for each button so that is how I am doing it.