Copyright Notice
Respect Original Works. Reprinted, please maintain the integrity of the article, and in the form of a hyperlink to indicate the original author "tingsking18" and the main site address, so that other friends can ask and correct.
Put Pushbutton written in the previous article into QT designer:
Pushbuttonplugin. h
# Include <qdesignercustomwidgetinterface> <br/> class pushbuttonplugin: Public qobject, public qdesignercustomwidgetinterface <br/>{< br/> q_object <br/> q_interfaces (qdesignercustomwidgetinterface) <br/> Public: <br/> pushbuttonplugin (qobject * parent = 0); <br/> qstring name () const; <br/> qstring includefile () const; <br/> qstring group () const; <br/> qicon icon () const; <br/> qstring tooltip () const; <br/> qstring whatsthis () const; <br/> bool iscontainer () const; <br/> qwidget * createwidget (qwidget * parent); <br/>}; <br/>
Pushbuttonplugin. cpp
# Include "pushbuttonplugin. H "<br/> # include" Pushbutton. H "<br/> # include <qtplugin> <br/> pushbuttonplugin: pushbuttonplugin (qobject * parent) <br/>: qobject (parent) <br/>{< br/>}< br/> qstring pushbuttonplugin: Name () const <br/>{< br/> return "Pushbutton "; <br/>}< br/> qstring pushbuttonplugin: includefile () const <br/>{< br/> return "Pushbutton. H "; <br/>}< br/> qstring pushbuttonplugin: group () const <br/>{< br/> return tr (" buttons "); <br/>}< br/> qicon pushbuttonplugin: icon () const <br/> {<br/> return qicon (":/images/bp_btn3.png "); <br/>}< br/> qstring pushbuttonplugin: tooltip () const <br/>{< br/> return tr ("an Pushbutton widget "); <br/>}< br/> qstring pushbuttonplugin: whatsthis () const <br/>{< br/> return tr ("This widget is Pushbutton widget "); <br/>}< br/> bool pushbuttonplugin: iscontainer () const <br/>{< br/> return false; <br/>}< br/> qwidget * pushbuttonplugin: createwidget (qwidget * parent) <br/>{< br/> return New Pushbutton ("Pushbutton", parent ); <br/>}</P> <p> q_export_plugin2 (pushbuttonplugin, pushbuttonplugin) <br/>
Pushbuttonplugin. Pro
Qt + = qt3support
Template = lib
Config + = designer plugin release
Headers = mpushbutton. h/
Mpushbuttonplugin. h
Sources = mpushbuttonplugin. cpp
Resources = clicklabel. qrc
Destdir = $ (qtdir)/plugins/designer