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. PROBLEM TO SIGNALS AND SLOTS
Forum Updated to NodeBB v4.3 + New Features

PROBLEM TO SIGNALS AND SLOTS

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 375 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.
  • G Offline
    G Offline
    Giakara
    wrote on last edited by
    #1

    I Create A custom widget Class in main window and i try to connect a slider from mainwindow to a function in Qustom class. App starts correctly but when i move the slider it gets The program has unexpectedly finished.Screenshot_8.png

    jsulmJ 1 Reply Last reply
    0
    • G Giakara

      I Create A custom widget Class in main window and i try to connect a slider from mainwindow to a function in Qustom class. App starts correctly but when i move the slider it gets The program has unexpectedly finished.Screenshot_8.png

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Giakara said in PROBLEM TO SIGNALS AND SLOTS:

      The program has unexpectedly finished

      So, did you use the debugger to see where and why it crashes?
      Is "window" a valid pointer?

      Also, please post code as text, not pictures.

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

      1 Reply Last reply
      2
      • G Offline
        G Offline
        Giakara
        wrote on last edited by
        #3

        The debugger shows an error about qtcreatordbext.dll not found

        QT_BEGIN_NAMESPACE
        namespace Ui { class MainWindow; class WindowWidget; }
        QT_END_NAMESPACE

        class WindowWidget : public QWidget {
        Q_OBJECT
        public:
        WindowWidget(QWidget *parent = nullptr) {

        //code//

               fast::SurfaceExtraction::pointer mSurfaceExtraction = fast::SurfaceExtraction::New();
               mSurfaceExtraction->setInputConnection(mSmoothing->getOutputPort());
               mSurfaceExtraction->setThreshold(0);
        
            };
            ~WindowWidget() {
                fast::Reporter::info() << "Trying to stop computation thread" << fast::Reporter::end();
                if(mThread != NULL) {
                    mThread->stop();
                    delete mThread;
                    mThread = NULL;
                }
                fast::Reporter::info() << "Computation thread stopped" << fast::Reporter::end();
            };
        public slots:
            }
            void updateThreshold(int value){
        
                mSurfaceExtraction->setThreshold(value);
        
            };
        
        private:
            fast::SurfaceExtraction::pointer mSurfaceExtraction;
            fast::ComputationThread* mThread;
            fast::View* mView;
            fast::GaussianSmoothingFilter::pointer mSmoothing;
        

        };
        class MainWindow : public QMainWindow
        {
        Q_OBJECT

        public:
        MainWindow(QWidget *parent = nullptr);
        ~MainWindow();

        private slots:

        void on_slider_valueChanged(int value);
        

        private:
        Ui::MainWindow *ui;
        WindowWidget *window;
        };

        cpp

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

        ui->setupUi(this);
        ui->verticalLayout->addWidget(window);
        //connect(ui->slider, &QSlider::valueChanged, std::bind(&WindowWidget::updateThreshold, this, std::placeholders::_1));
        

        }

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

        void MainWindow::on_slider_valueChanged(int value)
        {

        window->updateThreshold(value);

        }

        this is my code if i create o slider inside my Window it works (I m new to QT)

        jsulmJ Christian EhrlicherC 2 Replies Last reply
        0
        • G Giakara

          The debugger shows an error about qtcreatordbext.dll not found

          QT_BEGIN_NAMESPACE
          namespace Ui { class MainWindow; class WindowWidget; }
          QT_END_NAMESPACE

          class WindowWidget : public QWidget {
          Q_OBJECT
          public:
          WindowWidget(QWidget *parent = nullptr) {

          //code//

                 fast::SurfaceExtraction::pointer mSurfaceExtraction = fast::SurfaceExtraction::New();
                 mSurfaceExtraction->setInputConnection(mSmoothing->getOutputPort());
                 mSurfaceExtraction->setThreshold(0);
          
              };
              ~WindowWidget() {
                  fast::Reporter::info() << "Trying to stop computation thread" << fast::Reporter::end();
                  if(mThread != NULL) {
                      mThread->stop();
                      delete mThread;
                      mThread = NULL;
                  }
                  fast::Reporter::info() << "Computation thread stopped" << fast::Reporter::end();
              };
          public slots:
              }
              void updateThreshold(int value){
          
                  mSurfaceExtraction->setThreshold(value);
          
              };
          
          private:
              fast::SurfaceExtraction::pointer mSurfaceExtraction;
              fast::ComputationThread* mThread;
              fast::View* mView;
              fast::GaussianSmoothingFilter::pointer mSmoothing;
          

          };
          class MainWindow : public QMainWindow
          {
          Q_OBJECT

          public:
          MainWindow(QWidget *parent = nullptr);
          ~MainWindow();

          private slots:

          void on_slider_valueChanged(int value);
          

          private:
          Ui::MainWindow *ui;
          WindowWidget *window;
          };

          cpp

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

          ui->setupUi(this);
          ui->verticalLayout->addWidget(window);
          //connect(ui->slider, &QSlider::valueChanged, std::bind(&WindowWidget::updateThreshold, this, std::placeholders::_1));
          

          }

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

          void MainWindow::on_slider_valueChanged(int value)
          {

          window->updateThreshold(value);

          }

          this is my code if i create o slider inside my Window it works (I m new to QT)

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Giakara said in PROBLEM TO SIGNALS AND SLOTS:

          void updateThreshold(int value){

              mSurfaceExtraction->setThreshold(value);
          
          };
          

          Please check all your pointers and fix your debugger - people here are not debuggers to analize crashes in your code without having it...

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

          1 Reply Last reply
          0
          • G Giakara

            The debugger shows an error about qtcreatordbext.dll not found

            QT_BEGIN_NAMESPACE
            namespace Ui { class MainWindow; class WindowWidget; }
            QT_END_NAMESPACE

            class WindowWidget : public QWidget {
            Q_OBJECT
            public:
            WindowWidget(QWidget *parent = nullptr) {

            //code//

                   fast::SurfaceExtraction::pointer mSurfaceExtraction = fast::SurfaceExtraction::New();
                   mSurfaceExtraction->setInputConnection(mSmoothing->getOutputPort());
                   mSurfaceExtraction->setThreshold(0);
            
                };
                ~WindowWidget() {
                    fast::Reporter::info() << "Trying to stop computation thread" << fast::Reporter::end();
                    if(mThread != NULL) {
                        mThread->stop();
                        delete mThread;
                        mThread = NULL;
                    }
                    fast::Reporter::info() << "Computation thread stopped" << fast::Reporter::end();
                };
            public slots:
                }
                void updateThreshold(int value){
            
                    mSurfaceExtraction->setThreshold(value);
            
                };
            
            private:
                fast::SurfaceExtraction::pointer mSurfaceExtraction;
                fast::ComputationThread* mThread;
                fast::View* mView;
                fast::GaussianSmoothingFilter::pointer mSmoothing;
            

            };
            class MainWindow : public QMainWindow
            {
            Q_OBJECT

            public:
            MainWindow(QWidget *parent = nullptr);
            ~MainWindow();

            private slots:

            void on_slider_valueChanged(int value);
            

            private:
            Ui::MainWindow *ui;
            WindowWidget *window;
            };

            cpp

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

            ui->setupUi(this);
            ui->verticalLayout->addWidget(window);
            //connect(ui->slider, &QSlider::valueChanged, std::bind(&WindowWidget::updateThreshold, this, std::placeholders::_1));
            

            }

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

            void MainWindow::on_slider_valueChanged(int value)
            {

            window->updateThreshold(value);

            }

            this is my code if i create o slider inside my Window it works (I m new to QT)

            Christian EhrlicherC Online
            Christian EhrlicherC Online
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @Giakara said in PROBLEM TO SIGNALS AND SLOTS:

            fast::SurfaceExtraction::pointer mSurfaceExtraction = fast::SurfaceExtraction::New();

            Basic++ - it does not initialize the variable you want to.

            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
            0

            • Login

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