Place custom widgets in QT designer

Source: Internet
Author: User
Tags qt designer
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.