Results 1 to 4 of 4

Thread: simple QDialog

  1. #1
    Join Date
    Nov 2007
    Posts
    57
    Thanks
    36
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default simple QDialog

    Hello!

    I'd like to make a simple popup dialog that opens after my program is done running. I want it to say "Completed" and display an OK button which would simply close the dialog.
    So far I have this:

    Qt Code:
    1. QDialog okDialog(this, Qt::Dialog);
    2. QLabel doneLabel("Complete");
    3. QPushButton okButton;
    4. okDialog.resize(50,50);
    5.  
    6. okDialog.exec();
    7. okDialog.raise();
    8. okDialog.activateWindow();
    To copy to clipboard, switch view to plain text mode 

    I'd like to know how to add the okButton and the QLabel (wth thext) to the surface of my dialog. Thanks.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: simple QDialog


  3. The following user says thank you to jacek for this useful post:

    eric (14th December 2007)

  4. #3
    Join Date
    Nov 2007
    Posts
    57
    Thanks
    36
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: simple QDialog

    Thanks Jacek for the idea and congrats on becoming a Guru!

    I was wondering if you could display integers using message box?
    This below code works well:

    Qt Code:
    1. char message[] = "Text";
    2. QMessageBox::information(this, "Title", message, QMessageBox::Ok);
    To copy to clipboard, switch view to plain text mode 

    but when I replace "message" with an integer (int message = 1 it won't work.
    How do you display integers?
    For example if I want to say in the message boxt:

    "You had 5 files in this folder" and the number 5 was calculated by a formula, not typed in by a programmer.

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: simple QDialog

    Quote Originally Posted by eric View Post
    Thanks Jacek for the idea and congrats on becoming a Guru!
    Thank you.

    Quote Originally Posted by eric View Post
    How do you display integers?
    First you have to change them into a QStrings. For example using QString::number().

    Or even better use QObject::tr() (read the part about the n parameter).

  6. The following user says thank you to jacek for this useful post:

    eric (14th December 2007)

Similar Threads

  1. QDialog margin and spacing
    By TheRonin in forum Qt Programming
    Replies: 4
    Last Post: 29th October 2007, 10:11
  2. QDialog / QListView problem
    By harakiri in forum Qt Programming
    Replies: 1
    Last Post: 10th July 2007, 18:31
  3. Replies: 11
    Last Post: 31st May 2007, 01:11
  4. Resizing a QDialog to the content size
    By Nyphel in forum Qt Programming
    Replies: 8
    Last Post: 15th March 2007, 08:16
  5. Qdialog as a child widget
    By dave in forum Newbie
    Replies: 12
    Last Post: 14th November 2006, 09:43

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.