我有一组自定义小部件,我正在集成到Qt设计器中,当我尝试构建它时,它会抛出LNK2005
,LNK2019
和LNK1120
。它看起来集中在我的QtMaterialFabPlugin
文件上,所以我将基于此提供示例代码。它还基本上表示QtMaterialFabPlugin
的每个函数都已在相应的.obj
文件中定义。这是我的相关代码,非常感谢您对此的任何帮助。
QtMaterialFabPlugin.h:
#ifndef QTMATERIALFABPLUGIN_H
#define QTMATERIALFABPLUGIN_H
#include <QDesignerCustomWidgetInterface>
class QtMaterialFabPlugin : public QObject, public QDesignerCustomWidgetInterface
{
Q_OBJECT
Q_INTERFACES(QDesignerCustomWidgetInterface)
public:
QtMaterialFabPlugin(QObject *parent = 0);
bool isContainer() const;
bool isInitialized() const;
QIcon icon() const;
QString domXml() const;
QString group() const;
QString includeFile() const;
QString name() const;
QString toolTip() const;
QString whatsThis() const;
QWidget *createWidget(QWidget *parent);
void initialize(QDesignerFormEditorInterface *core);
private:
bool m_initialized;
};
#endif
QtMaterialFabPlugin.cpp:
#include "qtmaterialfab.h"
#include "qtmaterialfabplugin.h"
#include <QtPlugin>
QtMaterialFabPlugin::QtMaterialFabPlugin(QObject* parent) : QObject(parent) {
m_initialized = false;
}
void QtMaterialFabPlugin::initialize(QDesignerFormEditorInterface*) {
if (m_initialized) return;
m_initialized = true;
}
bool QtMaterialFabPlugin::isInitialized() const { return m_initialized; }
QWidget* QtMaterialFabPlugin::createWidget(QWidget* parent) {
return new QtMaterialFab(parent);
}
QString QtMaterialFabPlugin::name() const {
return QLatin1String("QtMaterialFab");
}
QString QtMaterialFabPlugin::group() const {
return QLatin1String("Material Widgets");
}
QIcon QtMaterialFabPlugin::icon() const { return QIcon(); }
QString QtMaterialFabPlugin::toolTip() const { return QLatin1String(""); }
QString QtMaterialFabPlugin::whatsThis() const { return QLatin1String(""); }
bool QtMaterialFabPlugin::isContainer() const { return false; }
QString QtMaterialFabPlugin::domXml() const {
return QLatin1String(
"<widget class=\"QtMaterialFab\" name=\"qtMaterialFab\">\n<widget>\n");
}
QString QtMaterialFabPlugin::includeFile() const {
return QLatin1String("qtmaterialfab.h");
}
Material-Widgets.pro:
CONFIG += plugin debug_and_release
TARGET = $$qtLibraryTarget(qtmaterialwidgetsplugin)
TEMPLATE =
HEADERS = qtmaterialappbarplugin.h qtmaterialautocompleteplugin.h qtmaterialavatarplugin.h qtmaterialbadgeplugin.h qtmaterialcheckboxplugin.h qtmaterialcircularprogressplugin.h qtmaterialdialogplugin.h qtmaterialdrawerplugin.h qtmaterialfabplugin.h qtmaterialflatbuttonplugin.h qtmaterialiconbuttonplugin.h qtmateriallistplugin.h qtmateriallistitemplugin.h qtmaterialmenuplugin.h qtmaterialprogressplugin.h qtmaterialradiobuttonplugin.h qtmaterialraisedbuttonplugin.h qtmaterialscrollbarplugin.h qtmaterialsliderplugin.h qtmaterialsnackbarplugin.h qtmaterialtableplugin.h qtmaterialtabsplugin.h qtmaterialtextfieldplugin.h qtmaterialtoggleplugin.h qtmaterialwidgets.h
SOURCES = qtmaterialsliderplugin.cpp qtmaterialappbarplugin.cpp qtmaterialautocompleteplugin.cpp qtmaterialavatarplugin.cpp qtmaterialbadgeplugin.cpp qtmaterialcheckboxplugin.cpp qtmaterialcircularprogressplugin.cpp qtmaterialdialogplugin.cpp qtmaterialdrawerplugin.cpp qtmaterialfabplugin.cpp qtmaterialflatbuttonplugin.cpp qtmaterialiconbuttonplugin.cpp qtmateriallistplugin.cpp qtmateriallistitemplugin.cpp qtmaterialmenuplugin.cpp qtmaterialprogressplugin.cpp qtmaterialradiobuttonplugin.cpp qtmaterialraisedbuttonplugin.cpp qtmaterialscrollbarplugin.cpp qtmaterialsnackbarplugin.cpp qtmaterialtableplugin.cpp qtmaterialtabsplugin.cpp qtmaterialtextfieldplugin.cpp qtmaterialtoggleplugin.cpp qtmaterialwidgets.cpp
RESOURCES = icons.qrc
LIBS += -L.
greaterThan(QT_MAJOR_VERSION, 4) {
QT += designer
} else {
CONFIG += designer
}
target.path = $$[QT_INSTALL_PLUGINS]/designer
INSTALLS += target
include(qtmaterialextrafiles.pri)
include(qtmaterialraisedbutton.pri)
include(qtmateriallist.pri)
include(qtmaterialradiobutton.pri)
include(qtmaterialslider.pri)
include(qtmaterialtextfield.pri)
include(qtmaterialtoggle.pri)
include(qtmaterialdialog.pri)
include(qtmaterialtable.pri)
include(qtmaterialautocomplete.pri)
include(qtmaterialbadge.pri)
include(qtmaterialcheckbox.pri)
include(qtmaterialavatar.pri)
include(qtmaterialcircularprogress.pri)
include(qtmaterialappbar.pri)
include(qtmaterialfab.pri)
include(qtmaterialdrawer.pri)
include(qtmaterialsnackbar.pri)
include(qtmaterialmenu.pri)
include(qtmateriallistitem.pri)
include(qtmaterialflatbutton.pri)
include(qtmaterialtabs.pri)
include(qtmaterialiconbutton.pri)
include(qtmaterialscrollbar.pri)
include(qtmaterialprogress.pri)
答案 0 :(得分:0)
糟糕,我只需添加
TEMPLATE = lib
到.pro
文件。