码迷,mamicode.com
首页 > 其他好文 > 详细

qt自定义控件

时间:2018-09-07 13:54:20      阅读:183      评论:0      收藏:0      [点我收藏+]

标签:pwd   .dll   自定义控件   target   template   get   eve   plugin   自定义   

一,首先新建一个功能,例如:spprogressbar

  spprogressbar.pro

CONFIG      += plugin debug_and_release
TARGET      = $$qtLibraryTarget(spprogressbarplugin)
TEMPLATE    = lib

DESTDIR     = $$PWD/../lib
HEADER_PATH = $$PWD/../../include
SOURCE_PATH = $$PWD/../../src

HEADERS     +=     $$PWD/spprogressbar.h

SOURCES     +=     $$PWD/spprogressbar.cpp

LIBS        += -L.

greaterThan(QT_MAJOR_VERSION, 4) {
    QT += designer
} else {
    CONFIG += designer
}

target.path = $$[QT_INSTALL_PLUGINS]/designer
INSTALLS    += target
INCLUDEPATH += $$HEADER_PATH/

  spprogressbar.h

#ifndef SPPROGRESSBAR_H
#define SPPROGRESSBAR_H

#include <QWidget>
#include <QPainter>
#include <QMouseEvent>

class SpProgressBar : public QWidget
{
    Q_OBJECT

public:
    SpProgressBar(QWidget *parent = 0);
};

#endif

  spprogressbar.cpp

#include "spprogressbar.h"

SpProgressBar::SpProgressBar(QWidget *parent) :
    QWidget(parent)
{

}

 

二,然后将编译生成的dll文件libspprogressbarplugin.dll放到Qt\Qt5.9.1\mingw53_32\plugins\designer下

三,重启designer就可以看到自动以的控件了

    

qt自定义控件

标签:pwd   .dll   自定义控件   target   template   get   eve   plugin   自定义   

原文地址:https://www.cnblogs.com/senior-engineer/p/9603867.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!