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 Child Window from Main Window as Class
Forum Updated to NodeBB v4.3 + New Features

QT Child Window from Main Window as Class

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 397 Views
  • 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.
  • F Offline
    F Offline
    fatih1
    wrote on 25 May 2020, 06:50 last edited by fatih1
    #1

    Hello everyone,

    I want to extend the QT Calculator Example so that I can perform numerical integrations.
    Link :https://doc.qt.io/qt-5/qtwidgets-widgets-calculator-example.html

    I want to have a main Calculator window and a Child Integral window which opens when I click on the Integral Button.
    Screenshot 2020-05-25 at 08.17.05.png

    Right Now the implementation of the Integral window is in the IntegralClicked Slot from the Main Calculator class.
    BUt I want to create a child Integral Class and I don't know how.

    this is the.h

    class IntegralWindow: public QDialog{
    Q_OBJECT
    public:
    explicit IntegralWindow(QWidget *parent=nullptr);
    ~IntegralWindow();
    private:
    QWidget *wdg;

    };

    class Calculator : public QWidget
    {
    Q_OBJECT

    public:
    Calculator(QWidget *parent = nullptr);

    private slots:
    void integralClicked();
    //! [0]

    //! [1]
    private:
    IntegralWindow *Int;

    this is the .cpp

    Calculator::Calculator(QWidget *parent)
    : QWidget(parent), sumInMemory(0.0), sumSoFar(0.0)
    , factorSoFar(0.0), waitingForOperand(true)
    {...}

    void Calculator::integralClicked(){

    Int = new IntegralWindow(this);
    Int->show();

    }

    Calculator.cpp

    ...
    void Calculator::onIntegralClicked(){
    IntegralWindow= new I
    }

    I get these symbol architecture undefined errors
    Undefined symbols for architecture x86_64:
    "IntegralWindow::IntegralWindow(QWidget*)", referenced from:
    Calculator::integralClicked() in calculator.o
    "IntegralWindow::~IntegralWindow()", referenced from:
    vtable for IntegralWindow in moc_calculator.o
    "IntegralWindow::~IntegralWindow()", referenced from:
    vtable for IntegralWindow in moc_calculator.o
    "non-virtual thunk to IntegralWindow::~IntegralWindow()", referenced from:
    vtable for IntegralWindow in moc_calculator.o
    "non-virtual thunk to IntegralWindow::~IntegralWindow()", referenced from:
    vtable for IntegralWindow in moc_calculator.o
    ld: symbol(s) not found for architecture x86_64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    make: *** [calculator.app/Contents/MacOS/calculator] Error 1
    08:32:09: The process "/usr/bin/make" exited with code 2.
    Error while building/deploying project calculator (kit: Desktop Qt 5.14.2 clang 64bit)
    When executing step "Make"

    What exactly is wrong

    Note that I have cut out the unneccessary parts
    I also connected the integral clicked slot with the button (that;s not the problem)

    J 1 Reply Last reply 25 May 2020, 06:52
    0
    • F Offline
      F Offline
      fatih1
      wrote on 25 May 2020, 07:52 last edited by
      #5

      Hello, yes I could finally solve it.
      I had got some problems with polymorphism

      1 Reply Last reply
      0
      • F fatih1
        25 May 2020, 06:50

        Hello everyone,

        I want to extend the QT Calculator Example so that I can perform numerical integrations.
        Link :https://doc.qt.io/qt-5/qtwidgets-widgets-calculator-example.html

        I want to have a main Calculator window and a Child Integral window which opens when I click on the Integral Button.
        Screenshot 2020-05-25 at 08.17.05.png

        Right Now the implementation of the Integral window is in the IntegralClicked Slot from the Main Calculator class.
        BUt I want to create a child Integral Class and I don't know how.

        this is the.h

        class IntegralWindow: public QDialog{
        Q_OBJECT
        public:
        explicit IntegralWindow(QWidget *parent=nullptr);
        ~IntegralWindow();
        private:
        QWidget *wdg;

        };

        class Calculator : public QWidget
        {
        Q_OBJECT

        public:
        Calculator(QWidget *parent = nullptr);

        private slots:
        void integralClicked();
        //! [0]

        //! [1]
        private:
        IntegralWindow *Int;

        this is the .cpp

        Calculator::Calculator(QWidget *parent)
        : QWidget(parent), sumInMemory(0.0), sumSoFar(0.0)
        , factorSoFar(0.0), waitingForOperand(true)
        {...}

        void Calculator::integralClicked(){

        Int = new IntegralWindow(this);
        Int->show();

        }

        Calculator.cpp

        ...
        void Calculator::onIntegralClicked(){
        IntegralWindow= new I
        }

        I get these symbol architecture undefined errors
        Undefined symbols for architecture x86_64:
        "IntegralWindow::IntegralWindow(QWidget*)", referenced from:
        Calculator::integralClicked() in calculator.o
        "IntegralWindow::~IntegralWindow()", referenced from:
        vtable for IntegralWindow in moc_calculator.o
        "IntegralWindow::~IntegralWindow()", referenced from:
        vtable for IntegralWindow in moc_calculator.o
        "non-virtual thunk to IntegralWindow::~IntegralWindow()", referenced from:
        vtable for IntegralWindow in moc_calculator.o
        "non-virtual thunk to IntegralWindow::~IntegralWindow()", referenced from:
        vtable for IntegralWindow in moc_calculator.o
        ld: symbol(s) not found for architecture x86_64
        clang: error: linker command failed with exit code 1 (use -v to see invocation)
        make: *** [calculator.app/Contents/MacOS/calculator] Error 1
        08:32:09: The process "/usr/bin/make" exited with code 2.
        Error while building/deploying project calculator (kit: Desktop Qt 5.14.2 clang 64bit)
        When executing step "Make"

        What exactly is wrong

        Note that I have cut out the unneccessary parts
        I also connected the integral clicked slot with the button (that;s not the problem)

        J Offline
        J Offline
        jsulm
        Lifetime Qt Champion
        wrote on 25 May 2020, 06:52 last edited by
        #2

        @fatih1 said in QT Child Window from Main Window as Class:

        IntegralWindow::IntegralWindow

        You did not define it, did you?
        Same for IntegralWindow::~IntegralWindow()

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        F 1 Reply Last reply 25 May 2020, 07:14
        0
        • J jsulm
          25 May 2020, 06:52

          @fatih1 said in QT Child Window from Main Window as Class:

          IntegralWindow::IntegralWindow

          You did not define it, did you?
          Same for IntegralWindow::~IntegralWindow()

          F Offline
          F Offline
          fatih1
          wrote on 25 May 2020, 07:14 last edited by
          #3

          Hello @jsulm
          Right now I don't get these errors Screenshot 2020-05-25 at 09.13.36.png Screenshot 2020-05-25 at 09.13.24.png Screenshot 2020-05-25 at 09.12.52.png Screenshot 2020-05-25 at 09.12.38.png

          BUt the window does not open

          J 1 Reply Last reply 25 May 2020, 07:50
          0
          • F fatih1
            25 May 2020, 07:14

            Hello @jsulm
            Right now I don't get these errors Screenshot 2020-05-25 at 09.13.36.png Screenshot 2020-05-25 at 09.13.24.png Screenshot 2020-05-25 at 09.12.52.png Screenshot 2020-05-25 at 09.12.38.png

            BUt the window does not open

            J Offline
            J Offline
            jsulm
            Lifetime Qt Champion
            wrote on 25 May 2020, 07:50 last edited by
            #4

            @fatih1 Did you connect Calculator::integralClicked() to the signal from the button?

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • F Offline
              F Offline
              fatih1
              wrote on 25 May 2020, 07:52 last edited by
              #5

              Hello, yes I could finally solve it.
              I had got some problems with polymorphism

              1 Reply Last reply
              0

              1/5

              25 May 2020, 06:50

              • Login

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