Results 1 to 7 of 7

Thread: problem in Qt4 dialog

  1. #1
    Join Date
    Jul 2009
    Location
    Bangalore
    Posts
    68
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default problem in Qt4 dialog

    Hi All,

    I have created a dialog(Disp) in Qt-4.2 which has 3 lineEdits namely X,Y,Z when the user press a key from keyboard a new diaolg(DatumForm) will open which has 4 namely lineEdits Sl.No, Xdat, Ydat,Zdat and user will enter some values in the lineEdits when he press the Emter key from keyboard the values of Xdat, Ydat,Zdat sholud be displayed in X,Y,Z lineEdits....

    I am not able to display values in Dispd dialog .. here is the code snippet

    Qt Code:
    1. void Disp::openDatumForm()
    2. {
    3. DatumForm *datumform = new DatumForm(this);
    4. datumform->show();
    5. // datumform->setWFlags();
    6. datumform->move(35, 90);
    7. if( datumform->exec() == QDialog::Accepted)
    8. {
    9. DatumVal = Datumno_Val;
    10. XVal = Xdatum_Val;
    11. YVal = Ydatum_Val;
    12. ZVal = Zdatum_Val;
    13. datuminitial();
    14. }
    15. }
    To copy to clipboard, switch view to plain text mode 

    But the same thing is working in Qt-3.3 and also i have attached the ui forms

    Please help us.
    Attached Files Attached Files
    Last edited by wysota; 27th August 2009 at 09:59. Reason: missing [code] tags
    Thanks & Regards
    Sandeep G.R.

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: problem in Qt4 dialog

    oftop: you don't need to call QDialog::show, because then you call QDialog::exec. btw, you don't free memory of you dialog. it would be better if you create that dialog in a stack, like this
    Qt Code:
    1. void Disp:penDatumForm()
    2. {
    3. DatumForm datumform(this);
    4. datumform.move(35, 90);
    5. if(datumform.exec() == QDialog::Accepted) {
    6. DatumVal = Datumno_Val;
    7. XVal = Xdatum_Val;
    8. YVal = Ydatum_Val;
    9. ZVal = Zdatum_Val;
    10. datuminitial();
    11. }
    12. }
    To copy to clipboard, switch view to plain text mode 
    ps. could you attach minimal compilable example which reproduces the problem?
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. #3
    Join Date
    Jul 2009
    Location
    Bangalore
    Posts
    68
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: problem in Qt4 dialog

    Thanks for the reply,

    i tried with your code but i same problem till now i was using Qt-3.3 and i have done the applications using Qt-3.3 now i have migrated to Qt-4.2

    I have attached the .cpp and .h file of the applications you can go through it and let me know where i am going wrong.
    Attached Files Attached Files
    Thanks & Regards
    Sandeep G.R.

  4. #4
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: problem in Qt4 dialog

    ok, the problem is in Disp:: openDatumForm in this line
    Qt Code:
    1. ...
    2. if(datumform.exec() == QDialog::Accepted)
    3. ...
    To copy to clipboard, switch view to plain text mode 
    when you close this dialog by Alt+F4 then the result of exec will be QDialog::Rejected and you pass this block
    Qt Code:
    1. {
    2. DatumVal = Datumno_Val;
    3. XVal = Xdatum_Val;
    4. YVal = Ydatum_Val;
    5. ZVal = Zdatum_Val;
    6. datuminitial();
    7. }
    To copy to clipboard, switch view to plain text mode 
    there is two ways:
    add a "OK" button in that dialog and connect signal QPushButton::clicked with QDialog::accept and leave this code unchanged
    Qt Code:
    1. void Disp::openDatumForm()
    2. {
    3. DatumForm datumform(this);
    4. datumform.move(35, 90);
    5. if(datumform.exec() == QDialog::Accepted) {
    6. DatumVal = Datumno_Val;
    7. XVal = Xdatum_Val;
    8. YVal = Ydatum_Val;
    9. ZVal = Zdatum_Val;
    10. datuminitial();
    11. }
    12. }
    To copy to clipboard, switch view to plain text mode 
    the second ways is: to use code like this
    Qt Code:
    1. void Disp::openDatumForm()
    2. {
    3. DatumForm datumform(this);
    4. datumform.move(35, 90);
    5. datumform.exec();
    6. DatumVal = Datumno_Val;
    7. XVal = Xdatum_Val;
    8. YVal = Ydatum_Val;
    9. ZVal = Zdatum_Val;
    10. datuminitial();
    11. }
    To copy to clipboard, switch view to plain text mode 
    in this case there is no need to add extra button in the dialog, but you also lose checking of the dialog acception or rejection.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  5. #5
    Join Date
    Jul 2009
    Location
    Bangalore
    Posts
    68
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: problem in Qt4 dialog

    I tried with both the ways but i am not able to display the values in the Disp form same problem. During the start of the applications the lineEdits sholud display 0.000 and that is not happening here is start up code snippet..

    Qt Code:
    1. Disp::Disp (QDialog *parent)
    2. :QDialog(parent)
    3. {
    4.  
    5. setupUi(this);
    6.  
    7. qDebug( "Init Function ( During StartUp)" );
    8.  
    9. xlineEdit->setText("0.000");
    10.  
    11. ylineEdit->setText("0.000");
    12.  
    13. zlineEdit->setText("0.000");
    14.  
    15. decimals_mm = 3;
    16. decimals_inch = 4;
    17. datuminitial();
    18. }
    To copy to clipboard, switch view to plain text mode 

    Please see my code attached and help us.
    Last edited by wysota; 27th August 2009 at 10:01. Reason: missing [code] tags
    Thanks & Regards
    Sandeep G.R.

  6. #6
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: problem in Qt4 dialog

    I don't understand what you need...
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  7. #7
    Join Date
    Jul 2009
    Location
    Bangalore
    Posts
    68
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: problem in Qt4 dialog

    When i run my application all the lineEdits in Disp Form should display 0.000 this is done by
    Qt Code:
    1. xlineEdit->setText("0.000");
    2. ylineEdit->setText("0.000");
    3. zlineEdit->setText("0.000");
    To copy to clipboard, switch view to plain text mode 

    but when i run the application it is displaying bank in all the lineEdits.
    Last edited by wysota; 27th August 2009 at 10:01. Reason: missing [code] tags
    Thanks & Regards
    Sandeep G.R.

Similar Threads

  1. Weird problem: multithread QT app kills my linux
    By Ishark in forum Qt Programming
    Replies: 2
    Last Post: 8th August 2008, 09:12
  2. Steps in solving a programming problem?
    By triperzonak in forum General Programming
    Replies: 8
    Last Post: 5th August 2008, 08:47
  3. Communication between MainWindow and a dialog
    By Backslash in forum Newbie
    Replies: 9
    Last Post: 3rd August 2007, 04:27
  4. Replies: 3
    Last Post: 23rd July 2006, 18:02
  5. Show/hide part of dialog with resizing.
    By Spockmeat in forum Qt Tools
    Replies: 6
    Last Post: 7th June 2006, 08:22

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.