Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt inheritance
Forum Updated to NodeBB v4.3 + New Features

Qt inheritance

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 439 Views 4 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    qcoderpro
    wrote on last edited by qcoderpro
    #1

    Hi,

    What does that part of "implimentation" below mean simply please?

    class FindDialog : public QDialog  // header
    {
        Q_OBJECT
    
    public:
        FindDialog(QWidget *parent = 0);
    ...
    
    
    FindDialog::FindDialog(QWidget *parent)  // implimentation
        : QDialog(parent)
    {
    ...
    
    int main(int argc, char *argv[])   // main.cpp
    {
        QApplication app(argc, argv);
        FindDialog *dialog = new FindDialog;
        dialog->show();
        return app.exec();
    }
    

    Does that mean we send a pointer to QWidget to the base class, QDialog?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      You are passing the parent parameter to the base class.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      Q 1 Reply Last reply
      1
      • SGaistS SGaist

        Hi,

        You are passing the parent parameter to the base class.

        Q Offline
        Q Offline
        qcoderpro
        wrote on last edited by
        #3

        @SGaist

        And that parent parameter is a pointer to QWidget, yes?

        If yes, so our class "FindDialog" doesn't have a parent here and is a top-level widget in our project. Yes, please?

        Pl45m4P 1 Reply Last reply
        0
        • Q qcoderpro

          @SGaist

          And that parent parameter is a pointer to QWidget, yes?

          If yes, so our class "FindDialog" doesn't have a parent here and is a top-level widget in our project. Yes, please?

          Pl45m4P Offline
          Pl45m4P Offline
          Pl45m4
          wrote on last edited by
          #4

          @qcoderpro

          Yes, you didn't set any direct parent there.

          FindDialog *dialog = new FindDialog

          So it just shows one instance of your FindDialog which has QDialog as its base class


          If debugging is the process of removing software bugs, then programming must be the process of putting them in.

          ~E. W. Dijkstra

          Q 1 Reply Last reply
          2
          • Pl45m4P Pl45m4

            @qcoderpro

            Yes, you didn't set any direct parent there.

            FindDialog *dialog = new FindDialog

            So it just shows one instance of your FindDialog which has QDialog as its base class

            Q Offline
            Q Offline
            qcoderpro
            wrote on last edited by
            #5

            @Pl45m4
            Thank you.

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved