Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. How to add another constructor ?
Forum Updated to NodeBB v4.3 + New Features

How to add another constructor ?

Scheduled Pinned Locked Moved Unsolved C++ Gurus
2 Posts 2 Posters 383 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.
  • A Offline
    A Offline
    Anonymous_Banned275
    wrote on 2 Jan 2023, 17:58 last edited by
    #1

    OK, I git hopelessly lost in "put the code in "backticks" ,,,"

    I call the class with this

    TERMINAL_MainWindow *MW = new TERMINAL_MainWindow();
    mdiArea->addSubWindow(MW)->
    // setWindowState(Qt::WindowMinimized) ;
    setWindowState(Qt::WindowMinimized) ;
    text = "Bluetooth (serial) terminal ";
    MW->setWindowTitle(text);

    it passes "null pointer" as parent...

    How do I pass a option to run SPECIFIC constructor ?
    What has to be changed ?

    I would prefer to build another class , if feasible, in SAME project.

    TERMINAL_MainWindow::TERMINAL_MainWindow(QWidget *parent) :
    QMainWindow(parent),
    m_ui(new Ui::TERMINAL_MainWindow),
    m_status(new QLabel),
    m_console(new Console),
    m_settings(new SettingsDialog),
    //! [1]
    m_serial(new QSerialPort(this))
    //! [1]
    {

    C 1 Reply Last reply 2 Jan 2023, 18:01
    0
    • A Anonymous_Banned275
      2 Jan 2023, 17:58

      OK, I git hopelessly lost in "put the code in "backticks" ,,,"

      I call the class with this

      TERMINAL_MainWindow *MW = new TERMINAL_MainWindow();
      mdiArea->addSubWindow(MW)->
      // setWindowState(Qt::WindowMinimized) ;
      setWindowState(Qt::WindowMinimized) ;
      text = "Bluetooth (serial) terminal ";
      MW->setWindowTitle(text);

      it passes "null pointer" as parent...

      How do I pass a option to run SPECIFIC constructor ?
      What has to be changed ?

      I would prefer to build another class , if feasible, in SAME project.

      TERMINAL_MainWindow::TERMINAL_MainWindow(QWidget *parent) :
      QMainWindow(parent),
      m_ui(new Ui::TERMINAL_MainWindow),
      m_status(new QLabel),
      m_console(new Console),
      m_settings(new SettingsDialog),
      //! [1]
      m_serial(new QSerialPort(this))
      //! [1]
      {

      C Offline
      C Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 2 Jan 2023, 18:01 last edited by
      #2

      @AnneRanch said in How to add another constructor ?:

      How do I pass a option to run SPECIFIC constructor ?

      Simply change your ctor to get a- QWidget pointer as first parameter - it's nothing more than a normal function.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      1

      1/2

      2 Jan 2023, 17:58

      • Login

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