Results 1 to 8 of 8

Thread: Why is QDialog.show() overriding my lineEdit text?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2012
    Posts
    98
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    11

    Default Why is QDialog.show() overriding my lineEdit text?

    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.
    Last edited by tescrin; 18th June 2012 at 21:54.

Similar Threads

  1. Clear text of LineEdit
    By stbb24 in forum Qt Programming
    Replies: 7
    Last Post: 12th June 2012, 14:30
  2. how to show a intger value in LineEdit
    By gauravg in forum Qt Programming
    Replies: 2
    Last Post: 28th February 2012, 11:01
  3. Replies: 9
    Last Post: 25th March 2011, 22:22
  4. lineEdit's setSelection - How to show more text?
    By squidge in forum Qt Programming
    Replies: 3
    Last Post: 30th January 2010, 18:22
  5. Get text from dynamic lineedit
    By wirasto in forum Qt Programming
    Replies: 1
    Last Post: 13th January 2010, 19:56

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.