Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. basic C++ question...

basic C++ question...

Scheduled Pinned Locked Moved C / C++ / MFC
c++designhelptutorialquestion
5 Posts 3 Posters 8 Views 1 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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    Qt project creates 'folders" , for lack of other terminology headers sources forms resulting in this constructor

    #include "mainwindow.h"
    #include "ui_mainwindow.h"

    MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
    {
    ui->setupUi(this);
    }

    MainWindow::~MainWindow()
    {
    delete ui;
    }

    I am trying to add "forms " to my exiting project. I follow the Qt menus... but I do not know how to modify my constructor.

    #ifdef BYPASS
    MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
    #endif

    CCC_MdiChild::CCC_MdiChild()
    {
    setAttribute(Qt::WA_DeleteOnClose);
    isUntitled = true;
    }

    Please help me to understand what Qt did and how to modify
    my constructor so I can access my "form".
    The verbal description / code annotation would be appreciated.
    Thanks

    K 1 Reply Last reply
    0
    • L Lost User

      Qt project creates 'folders" , for lack of other terminology headers sources forms resulting in this constructor

      #include "mainwindow.h"
      #include "ui_mainwindow.h"

      MainWindow::MainWindow(QWidget *parent)
      : QMainWindow(parent)
      , ui(new Ui::MainWindow)
      {
      ui->setupUi(this);
      }

      MainWindow::~MainWindow()
      {
      delete ui;
      }

      I am trying to add "forms " to my exiting project. I follow the Qt menus... but I do not know how to modify my constructor.

      #ifdef BYPASS
      MainWindow::MainWindow(QWidget *parent)
      : QMainWindow(parent)
      , ui(new Ui::MainWindow)
      #endif

      CCC_MdiChild::CCC_MdiChild()
      {
      setAttribute(Qt::WA_DeleteOnClose);
      isUntitled = true;
      }

      Please help me to understand what Qt did and how to modify
      my constructor so I can access my "form".
      The verbal description / code annotation would be appreciated.
      Thanks

      K Offline
      K Offline
      k5054
      wrote on last edited by
      #2

      This is not a C++ question, basic or otherwise. It is a QT question. You will probably get a better answer from a QT specific forum.

      Keep Calm and Carry On

      L 1 Reply Last reply
      0
      • K k5054

        This is not a C++ question, basic or otherwise. It is a QT question. You will probably get a better answer from a QT specific forum.

        Keep Calm and Carry On

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        Could you at least read this for me - in English - in generic way ? It is C++_ syntax I am having problems with. Would appreciate that.

        MainWindow::MainWindow(QWidget *parent)
        : QMainWindow(parent)
        , ui(new Ui::MainWindow)

        D L 2 Replies Last reply
        0
        • L Lost User

          Could you at least read this for me - in English - in generic way ? It is C++_ syntax I am having problems with. Would appreciate that.

          MainWindow::MainWindow(QWidget *parent)
          : QMainWindow(parent)
          , ui(new Ui::MainWindow)

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          It's the constructor of a class called MainWindow. QMainWindow and ui are being initialized using an initialization list.

          "One man's wage rise is another man's price increase." - Harold Wilson

          "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

          "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

          1 Reply Last reply
          0
          • L Lost User

            Could you at least read this for me - in English - in generic way ? It is C++_ syntax I am having problems with. Would appreciate that.

            MainWindow::MainWindow(QWidget *parent)
            : QMainWindow(parent)
            , ui(new Ui::MainWindow)

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            It is a single parameter constructor of the MainWindow class. The constructor accepts a single parameter which is a pointer to a QWidget object. The constructor sets its QMainWindow property to the input parameter - in this case the pointer named parent. It then sets its ui property by calling the Ui::MainWindow constructor, to create a new object of that class. To find out what the latter returns you need to look at the Ui class documentation.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups