当前位置:   article > 正文

error: LNK2001: 无法解析的外部符号 “public: virtual struct QMetaObject const * __cdecl_"error: lnk2001: 无法解析的外部符号 \"public: virtual struc

"error: lnk2001: 无法解析的外部符号 \"public: virtual struct qmetaobject const"

Qt系列文章目录

前言

我在代码中加入了对应的信号和槽,但编译仍然报错:

#ifndef PROJECTWIN_H
#define PROJECTWIN_H



namespace Ui {
class ProjectWin;
}


ProjectWin类声明头文件
class ProjectWin : public QWidget
{
    Q_OBJECT
public:
    static ProjectWin* getInstance();
    ~ProjectWin();

    FileMonitorMgr *m_fileMgr;
    QString m_paraFolder;
private:
    QTreeWidget* m_picTree;
//    QTreeWidget* m_paraTree;
    QWidget* m_naviWgt;

private:
    void initWidget();
    void initPicTree();
    void readParaFile(QString filePath);
private:
   
    QTextEdit*  m_paraText;
   

    static ProjectWin* m_pInstance;
private:
    explicit ProjectWin(QWidget *parent = nullptr);
    static void destroyInstance();

public Q_SLOTS:
   
    void slotParaInfo(QString imageName);
};

#endif // PROJECTWIN_H

ProjectWin类实现
#include "ProjectWin.h"
#include "ui_ProjectWin.h"

#pragma execution_character_set("utf-8")


ProjectWin* ProjectWin::m_pInstance = nullptr;

ProjectWin* ProjectWin::getInstance()
{
    if(!m_pInstance)
    {
        m_pInstance = new ProjectWin();
        atexit(destroyInstance);
    }
    return m_pInstance;
}

void ProjectWin::destroyInstance()
{
    if(m_pInstance)
    {
        delete m_pInstance;
        m_pInstance = nullptr;
    }
}

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

ProjectWin::ProjectWin(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::ProjectWin)
{
    ui->setupUi(this);

 

    //图像参数
    m_tabWidgetPara = new QTabWidget();
    m_paraText = new QTextEdit();
    m_tabWidgetPara->addTab(m_paraText, u8"图像参数数据");
    m_tabWidgetPara->setStyleSheet("border: 0");
    m_paraText->setStyleSheet("border: 0");

//    m_tabWidgetPara->setTabText(0, u8"图像参数数据");

   
    // 设置窗口的主布局
   
    this->setLayout(mainLayout);
}

void ProjectWin::onItemClicked(QTreeWidgetItem *item, int column)
{
    QString imageName = item->text(0);
    emit sigShowImageBorder(imageName);
}

void ProjectWin::initWidget()
{

    //    m_picTree->header()->hide();//设置隐藏头
}


void ProjectWin::slotParaInfo(QString imageName)
{
    QString fullPath = m_paraFolder + "/";
    QDir directory(m_paraFolder);
    QStringList filters;
    filters << "*.txt";

    directory.setNameFilters(filters);
    directory.setFilter(QDir::Files | QDir::NoDotAndDotDot);

    QFileInfoList fileInfoList = directory.entryInfoList();
    for (const QFileInfo &fileInfo : fileInfoList) {
        //        qDebug() << "Found:" << fileInfo.absoluteFilePath();
        QString fullPath = fileInfo.absoluteFilePath();
        if(imageName == fileInfo.fileName())
        {
            fullPath += imageName;
            readParaFile(m_paraFolder);
        }
    }
}

GraphicsView类实现实现
#ifndef GRAPHICSVIEW_H
#define GRAPHICSVIEW_H

#include <QtWidgets>
#include <QGraphicsView>
#include "GraphicsScene.h"
#include "GraphicsItem.h"

//#include <QGraphicViewMouseEvent>

class GraphicsScene;

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


    }

protected:
    void mousePressEvent(QMouseEvent *event) override
    {
        if (event->button() == Qt::LeftButton && event->modifiers() == Qt::ControlModifier) {
            m_isMousePressed = true;
            m_lastMousePos = event->pos();
            setCursor(Qt::ClosedHandCursor);
        } else {
            if (event->button() == Qt::LeftButton) {
                QGraphicsItem *item = itemAt(event->pos());
                if(item)
                {
                    GraphicsItem* selectedItem = dynamic_cast<GraphicsItem*>(item);
                    if(selectedItem)
                    {
                        QString imageName = selectedItem->getImageName();
                        emit imageNameSelected(imageName);
                    }
                }
                setDragMode(RubberBandDrag);
                pressPosition = event->pos();
                m_startScenePos = mapToScene(event->pos());
                m_rubberBandDragging = true;
                m_multipleItemsSelected = (scene()->selectedItems().size() > 1);
            }
            QGraphicsView::mousePressEvent(event);
        }
    }

private:
    
Q_SIGNALS:
    void imageNameSelected(QString imageName);
};

#endif // GRAPHICSVIEW_H


ImageManager类定义
#ifndef IMAGEMANAGER_H
#define IMAGEMANAGER_H

#include <QWidget>
#include <QVector>
#include <QImage>
#include <QVBoxLayout>
#include "GraphicsItem.h"
#include "GraphicsView.h"
#include "GraphicsScene.h"
#include "ProjectWin.h"

class ImageManager : public QWidget
{
    Q_OBJECT
public:
    explicit ImageManager(/*ProjectWin* projectWin,*/QWidget *parent = nullptr);

private:
    GraphicsScene* m_scene;
    GraphicsView*  m_view;
    GraphicsItem*  m_item;
    QVector<GraphicsItem*> m_items;
    QVBoxLayout*   m_layout;

    QString m_watchPath;

//    ProjectWin* m_projectWin;
public Q_SLOTS:
    void setImagePosition(QVector<QString> &filesVec, QString &path, int groupType);

Q_SIGNALS:

};

#endif // IMAGEMANAGER_H


#include "ImageManager.h"
#include "ProjectWin.h"
#include <QMetaObject>

ImageManager::ImageManager(/*ProjectWin* projectWin,*/QWidget* parent)
    : QWidget(parent)/*, m_projectWin(projectWin)*//*, m_scene(new GraphicsScene(this)), m_view(new GraphicsView()), m_layout(new QVBoxLayout(this))*/ {

    m_scene = new GraphicsScene(this);
	m_view = new GraphicsView;

    


    m_layout = new QVBoxLayout(this);
    m_layout->addWidget(m_view);
	setLayout(m_layout);

    int winWidth = 2048;  //1642
    int winHeight = 1050;   //692
//    setFixedSize(winWidth, winHeight);
    resize(winWidth, winHeight);

	
    connect(m_view, &GraphicsView::imageNameSelected, ProjectWin::getInstance(), &ProjectWin::slotParaInfo);

}

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204
  • 205
  • 206
  • 207
  • 208
  • 209
  • 210
  • 211
  • 212
  • 213
  • 214
  • 215
  • 216
  • 217
  • 218
  • 219
  • 220
  • 221
  • 222
  • 223
  • 224
  • 225
  • 226
  • 227
  • 228
  • 229
  • 230
  • 231
  • 232
  • 233
  • 234
  • 235
  • 236
  • 237
  • 238
  • 239
  • 240
  • 241
  • 242
  • 243
  • 244
  • 245
  • 246
  • 247
  • 248
  • 249
  • 250
  • 251
  • 252
  • 253
  • 254
  • 255
  • 256
  • 257
  • 258
  • 259
  • 260
  • 261
  • 262
  • 263
  • 264

ImageManager.obj

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小丑西瓜9/article/detail/91755
推荐阅读
相关标签