Basically, I've subclassed QDoubleSpinBox with my own (also tried QSpinBox) and want to have it *START* as "0.0." I can get everything to work right but when I initialize the value and the code gets to the QDialog's "show()" function, it'll overwrite my text value back to "0.00") (or "0" respectively.) I know it seems odd but I *have* to have it start at "0.0".
As I debugged I found that the value is changed at QDialog's function "show()", (or more directly "setVisible(bool)" since that's what show() calls AFAIK.) I've tried to look through more of the (qt) source code to track the issue but I can't seem to figure out where it's at exactly. Why on earth would setVisible(bool)/show() change my values?!
Currently my only fix is VERY dirty; I had to make a public function that would initialize the value to what I wanted and put it all the way in the QApp's main function *after* show. Please help me write truly object oriented code and get around this. I have no qualms overriding setVisible if this has to be done as long as that's a feasible task.
P.S. Any explanation as to WHY setVisible changes values would also be spectacular...
EDIT: [Actually, it's worth noting that this happens possibly because I used Qt Designer (in the qt creator) to start the project and then "promoted" the widget to my custom one. Everything else works fine, but this is highly desired functionality. It might be that in the generated code the show function calls some initialization functions, but i don't see why it would.]
Nevermind this idea, I've gone through the generated code of the UI file and it does not reference the show or setVisible function.




Reply With Quote
Bookmarks