Results 1 to 3 of 3

Thread: What does this actually mean?

  1. #1
    Join Date
    Oct 2010
    Posts
    54
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default What does this actually mean?

    Hi all I have been messing around with QT for some time now, but every single time I copy this line out when creating my dialogs and I actually have no idea what it means...

    Therefore, What does this mean?

    Qt Code:
    1. OpenDialog::OpenDialog(QWidget *parent) :
    2. QDialog(parent),
    3. ui(new Ui::OpenDialog)
    To copy to clipboard, switch view to plain text mode 

    Ok so first off we are using the OpenDialog Constructor. We're pointing to the parent (what exactly is parent) which is of type QWidget. I think that's right. Ok next up we are inheriting the QDialog class (not to sure what the parent bit means) and then I get confused by the part at the end?

    Could someone please explain each part to me... I played around with Qt for a while not, but I think it's time I actually started to learn how it works

    Thanks for your time and trouble.

  2. #2
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: What does this actually mean?

    To understand it, you need to have basic knowledge about constructors in C++, read this one, you may find it useful : C++ constructor initialization list
    Then you can apply this knowledge to your dialog example.

  3. #3
    Join Date
    Oct 2010
    Location
    Berlin, Germany
    Posts
    358
    Thanks
    18
    Thanked 68 Times in 66 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: What does this actually mean?

    well... at first you need to read some C++-tutorials.

    what you see is the head of a "constructor" with an "initialization list". The constructor has one parameter, a pointer to a QWidget. this parameter is called "parent". It refers to the parent widget or is NULL if you want to create a custom widget. "QDialog(parent)" does not inherit anything. The class "OpenDialog" is inherited from QDialog. That's why the Constructor of QDialog is called. The next line (3) initializes the member variable "ui" with "new Ui::OpenDialog".

Tags for this Thread

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.