Unsolved Program doesn't execute anymore in Qt
-
Hello, I'm a beginner when it come to Qt and c++ and a few days ago I coded this program:
#include <QtWidgets/QApplication> #include <QtWidgets/QWidget> #include <QtWidgets/QHBoxLayout> #include <QtWidgets/QVBoxLayout> #include <QtWidgets/QPushButton> #include <QtWidgets/QRadioButton> #include <QtWidgets/QSlider> #include <QtWidgets/QGroupBox> #include <QtWidgets/QComboBox> #include <QtWidgets/QLabel> #include <QtWidgets/QMessageBox> #include <QtGui/QPainter> #include <QtGui/QScreen> #include <QtDataVisualization/QAbstract3DGraph> #include <Q3DSurface> #include "matrix.h" using namespace QtDataVisualization; const float longueurBarre = 1.0f; //X const float periode = 1500.0f; //Z const int sampleCountX = 100; const int nombrePasTemps = 10000; const int sampleCountZ = 100; const float k =406.0f; const float rho = 10490.0f; const float c=233.0f; const double diffKelvin =273.15; int main(int argc, char **argv) { QApplication app(argc, argv); Q3DSurface *graph = new Q3DSurface(); graph->setHorizontalAspectRatio(1.0); QWidget *container = QWidget::createWindowContainer(graph); if (!graph->hasContext()) { QMessageBox boiteMsg; boiteMsg.setText("Impossible d'initialiser le contexte OpenGL."); boiteMsg.exec(); return -1; } QSize screenSize = graph->screen()->size(); container->setMinimumSize(QSize(screenSize.width() / 2, screenSize.height() / 1.6)); container->setMaximumSize(screenSize); container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); container->setFocusPolicy(Qt::StrongFocus); QWidget *widget = new QWidget; QHBoxLayout *hLayout = new QHBoxLayout(widget); QVBoxLayout *vLayout = new QVBoxLayout(); hLayout->addWidget(container, 1); hLayout->addLayout(vLayout); vLayout->setAlignment(Qt::AlignTop); widget->setWindowTitle(QStringLiteral("Méthode explicite : Evolution de la température interne d'une barre")); graph->setAxisX(new QValue3DAxis); graph->setAxisY(new QValue3DAxis); graph->setAxisZ(new QValue3DAxis); QSurfaceDataProxy *graphProxy = new QSurfaceDataProxy(); QSurface3DSeries *graphSeries = new QSurface3DSeries(graphProxy); float stepX = (longueurBarre) / float(sampleCountX - 1); float stepZ = (periode) / float(sampleCountZ - 1); float pasTemps = (periode) / float(nombrePasTemps - 1); //MATRICE Matrix T(sampleCountX, nombrePasTemps); for(int i=0; i<sampleCountX; i++) T(i,0)=20-diffKelvin; for(int j=0; j<nombrePasTemps; j++) T(0,j)=50-diffKelvin; for(int j=0; j<nombrePasTemps; j++) T(sampleCountX - 1,j)=30-diffKelvin; for(int j=1; j<nombrePasTemps ; j++) for(int i=1; i<sampleCountX-1 ; i++) T(i,j)=T(i,j-1)+float((k*pasTemps)/(rho*c*stepX*stepX))*(T(i+1,j-1)-2*T(i,j-1)+T(i-1,j-1)); for(int j=0; j<nombrePasTemps ; j++) for(int i=0; i<sampleCountX ; i++) T(i,j)+=diffKelvin; //MATRICE QSurfaceDataArray *dataArray = new QSurfaceDataArray; dataArray->reserve(sampleCountZ); for (int i = 0 ; i < sampleCountZ ; i++) { QSurfaceDataRow *newRow = new QSurfaceDataRow(sampleCountX); float z = qMin(periode, (i * stepZ)); int index = 0; for (int j = 0; j < sampleCountX; j++) { float x = qMin(longueurBarre, (j * stepX)); float y =T(j,100*i); (*newRow)[index++].setPosition(QVector3D(x, y, z)); } *dataArray << newRow; } graphProxy->resetArray(dataArray); graphSeries->setDrawMode(QSurface3DSeries::DrawSurfaceAndWireframe); graphSeries->setFlatShadingEnabled(true); QLinearGradient gradient(0, 0, 1, 100); gradient.setColorAt(1.0, Qt::darkGreen); gradient.setColorAt(0.5, Qt::yellow); gradient.setColorAt(0.2, Qt::red); gradient.setColorAt(0.0, Qt::darkRed); graph->seriesList().at(0)->setBaseGradient(gradient); graph->seriesList().at(0)->setColorStyle(Q3DTheme::ColorStyleRangeGradient); graph->axisX()->setLabelFormat("%.2f"); graph->axisZ()->setLabelFormat("%.2f"); graph->axisX()->setRange(0, longueurBarre); graph->axisY()->setRange(20.0f, 50.0f); graph->axisZ()->setRange(0, periode); graph->axisX()->setLabelAutoRotation(30); graph->axisY()->setLabelAutoRotation(90); graph->axisZ()->setLabelAutoRotation(30); graph->addSeries(graphSeries); graph->seriesList().at(0)->setBaseGradient(gradient); graph->seriesList().at(0)->setColorStyle(Q3DTheme::ColorStyleRangeGradient); widget->show(); return app.exec(); }
It worked exactly as intended, and then I decided to hit build, the exe file didn't execute and said that it need dll files, so I put the needed dll files in the folder, they were : Qt5Datavizualisation.dll, Qt5Gui.dll, Qt5Core.dll, Qt5Widgets.dll, and the exe file still didn't execute.
So I try to execute it in Qt, and now the program don't work anymore. I tried to troubleshoot it by seeing if it can execute even a simple "Hello world" button but even that doesn't work.
Back to my original code now, it said that the failing module was icuin51.dll so I put that in the folder too, now it say that it's ntdll.dll that is the problem, and the exception code is c000007b.
I have no idea what the problem can be, it's really urgent, all I need is for it to work just once as I just need screenshot of the graph it display. If anyone could help me I would appreciate it greatly. -
-
After a chat with LeLev I found out that the problem doesn't come from my code but Qt itself since I can't even execute a blank code, so I'm going to reinstall Qt.