PROBLEM TO SIGNALS AND SLOTS
-
@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.
-
The debugger shows an error about qtcreatordbext.dll not found
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; class WindowWidget; }
QT_END_NAMESPACEclass 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_OBJECTpublic:
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)
-
@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...
-
@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.