mainwindow.obj:-1: error: LNK2019: ссылка на неразрешенный внешний символ "public: __cdecl OGLWidget::OGLWidget(class QWidget *)" (??0OGLWidget@@QEAA@PEAVQWidget@@@Z) в функции "public: void __cdecl Ui_MainWindow::setupUi(class QMainWindow *)" (?setupUi@Ui_MainWindow@@QEAAXPEAVQMainWindow@@@Z)
#ifndef OGLWIDGET_H#define OGLWIDGET_H#include <QOpenGLWidget>class OGLWidget : public QOpenGLWidget{private: int layerNumber = 0; QColor TransverFunction(short value); int clamp(int val, int min, int max);protected: void initializeGL(); void resizeGL(int width, int height); void paintGL();public: OGLWidget(QWidget *parent);};#endif // OGLWIDGET_H
#include "oglwidget.h"#include "bin.h"OGLWidget::OGLWidget(QWidget *parent) : QOpenGLWidget(parent){}int MainWindow::clamp(int val, int min, int max){ return val>max?max:val<min?min:val;}void OGLWidget::initializeGL(){ glClearColor( 1, 1, 1, 1);}QColor OGLWidget::TransverFunction(short value){ int newVal = clamp((value - min) * 255 / (max - min), 0, 255); return QColor::fromRgb(newVal, newVal, newVal, 255);}void OGLWidget::resizeGL(int width, int height){ glShadeModel(GL_SMOOTH); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, Bin.X, 0, Bin.Y, -1, 1); glViewport(0, 0, width, height);}void OGLWidget::paintGL(){ glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); glBegin(GL_QUADS); for (int x_coord = 0; x_coord < Bin.X - 1; x_coord++) for (int y_coord = 0; y_coord < Bin.Y - 1; y_coord++) { } glEnd();}
int MainWindow::clamp(int val, int min, int max){ return val>max?max:val<min?min:val;}
#-------------------------------------------------## Project created by QtCreator 2017-05-10T00:26:58##-------------------------------------------------QT += openglQT += core guigreaterThan(QT_MAJOR_VERSION, 4): QT += widgetsTARGET =tomogram_visualizerTEMPLATE = app# The following define makes your compiler emit warnings if you use# any feature of Qt which as been marked as deprecated (the exact warnings# depend on your compiler). Please consult the documentation of the# deprecated API in order to know how to port your code away from it.DEFINES += QT_DEPRECATED_WARNINGS# You can also make your code fail to compile if you use deprecated APIs.# In order to do so, uncomment the following line.# You can also select to disable deprecated APIs only up to a certain version of Qt.#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0SOURCES += main.cpp\ mainwindow.cpp \ bin.cpp \ oglwidget.cppHEADERS += mainwindow.h \ bin.h \ oglwidget.hFORMS += mainwindow.ui
#ifndef UI_MAINWINDOW_H#define UI_MAINWINDOW_H#include <QtCore/QVariant>#include <QtWidgets/QAction>#include <QtWidgets/QApplication>#include <QtWidgets/QButtonGroup>#include <QtWidgets/QGridLayout>#include <QtWidgets/QHeaderView>#include <QtWidgets/QLabel>#include <QtWidgets/QMainWindow>#include <QtWidgets/QSlider>#include <QtWidgets/QStatusBar>#include <QtWidgets/QToolBar>#include <QtWidgets/QVBoxLayout>#include <QtWidgets/QWidget>#include "oglwidget.h"QT_BEGIN_NAMESPACEclass Ui_MainWindow{public: QAction *actionOpen; QAction *actionGPU; QWidget *centralWidget; QGridLayout *gridLayout; QVBoxLayout *verticalLayout; QSlider *horizontalSlider; QSlider *horizontalSlider_2; QVBoxLayout *verticalLayout_2; QLabel *label; QSlider *verticalSlider; OGLWidget *openGLWidget; QToolBar *mainToolBar; QStatusBar *statusBar; void setupUi(QMainWindow *MainWindow) { if (MainWindow->objectName().isEmpty()) MainWindow->setObjectName(QStringLiteral("MainWindow")); MainWindow->resize(666, 479); actionOpen = new QAction(MainWindow); actionOpen->setObjectName(QStringLiteral("actionOpen")); actionGPU = new QAction(MainWindow); actionGPU->setObjectName(QStringLiteral("actionGPU")); actionGPU->setCheckable(true); centralWidget = new QWidget(MainWindow); centralWidget->setObjectName(QStringLiteral("centralWidget")); gridLayout = new QGridLayout(centralWidget); gridLayout->setSpacing(6); gridLayout->setContentsMargins(11, 11, 11, 11); gridLayout->setObjectName(QStringLiteral("gridLayout")); verticalLayout = new QVBoxLayout(); verticalLayout->setSpacing(6); verticalLayout->setObjectName(QStringLiteral("verticalLayout")); horizontalSlider = new QSlider(centralWidget); horizontalSlider->setObjectName(QStringLiteral("horizontalSlider")); horizontalSlider->setOrientation(Qt::Horizontal); verticalLayout->addWidget(horizontalSlider); horizontalSlider_2 = new QSlider(centralWidget); horizontalSlider_2->setObjectName(QStringLiteral("horizontalSlider_2")); horizontalSlider_2->setOrientation(Qt::Horizontal); verticalLayout->addWidget(horizontalSlider_2); gridLayout->addLayout(verticalLayout, 0, 1, 1, 2); verticalLayout_2 = new QVBoxLayout(); verticalLayout_2->setSpacing(6); verticalLayout_2->setObjectName(QStringLiteral("verticalLayout_2")); label = new QLabel(centralWidget); label->setObjectName(QStringLiteral("label")); verticalLayout_2->addWidget(label); verticalSlider = new QSlider(centralWidget); verticalSlider->setObjectName(QStringLiteral("verticalSlider")); verticalSlider->setOrientation(Qt::Vertical); verticalLayout_2->addWidget(verticalSlider); gridLayout->addLayout(verticalLayout_2, 1, 2, 1, 1); openGLWidget = new OGLWidget(centralWidget); openGLWidget->setObjectName(QStringLiteral("openGLWidget")); gridLayout->addWidget(openGLWidget, 1, 1, 1, 1); MainWindow->setCentralWidget(centralWidget); mainToolBar = new QToolBar(MainWindow); mainToolBar->setObjectName(QStringLiteral("mainToolBar")); MainWindow->addToolBar(Qt::TopToolBarArea, mainToolBar); statusBar = new QStatusBar(MainWindow); statusBar->setObjectName(QStringLiteral("statusBar")); MainWindow->setStatusBar(statusBar); mainToolBar->addAction(actionOpen); mainToolBar->addSeparator(); mainToolBar->addAction(actionGPU); retranslateUi(MainWindow); QObject::connect(actionOpen, SIGNAL(triggered()), MainWindow, SLOT(OpenFile())); QObject::connect(actionGPU, SIGNAL(triggered()), MainWindow, SLOT(UseGPU())); QMetaObject::connectSlotsByName(MainWindow); } // setupUi void retranslateUi(QMainWindow *MainWindow) { MainWindow->setWindowTitle(QApplication::translate("MainWindow", "MainWindow", Q_NULLPTR)); actionOpen->setText(QApplication::translate("MainWindow", "Open", Q_NULLPTR)); actionOpen->setShortcut(QApplication::translate("MainWindow", "Ctrl+O", Q_NULLPTR)); actionGPU->setText(QApplication::translate("MainWindow", "GPU", Q_NULLPTR)); label->setText(QApplication::translate("MainWindow", "TextLabel", Q_NULLPTR)); } // retranslateUi};namespace Ui { class MainWindow: public Ui_MainWindow {};} // namespace UiQT_END_NAMESPACE#endif // UI_MAINWINDOW_H
C++ (Qt)#include "oglwidget.h"#include "bin.h" OGLWidget::OGLWidget(QWidget *parent) : QOpenGLWidget(parent){ } int MainWindow::clamp(int val, int min, int max){ return val>max?max:val<min?min:val;}...
#ifndef MAINWINDOW_H#define MAINWINDOW_H#include "bin.h"#include <QMainWindow>#include <QLabel>#include "oglwidget.h"namespace Ui {class MainWindow;}class MainWindow : public QMainWindow{ Q_OBJECTpublic: explicit MainWindow(QWidget *parent = 0); ~MainWindow();private slots: void OpenFile(); void UseGPU();private: int min = -1000; int max = 2000; Ui::MainWindow *ui; QLabel* currentLevel; QLabel* countFPS; OGLWidget* ogl;};#endif // MAINWINDOW_H
#include "mainwindow.h"#include "ui_mainwindow.h"#include <QtWidgets>#include <QFileDialog>MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow){ ui->setupUi(this); ui->label->setText(QString::number(min)); ogl = new OGLWidget(this); ui->verticalLayout_2->addWidget(ogl, 0); currentLevel = new QLabel; countFPS = new QLabel; ui->statusBar->addWidget(currentLevel, 0); currentLevel->setText("Current Level: "); ui->statusBar->addWidget(countFPS, 0); countFPS->setText("FPS: ");}MainWindow::~MainWindow(){ delete ui;}