Qt Custom Controls

reference:

https://www.cnblogs.com/georgeOfChina/p/7773141.html

 

 

1, open QtCreator, used here is Qt5.10.1 + MSVC2015_32-bit environment.

New projects, other projects -> Qt4 Designer Custom Controls -> Settings class names begin with a capital [Test] to determine, at this time no ui file

2, delete Test.h and Test.cpp, right-engineering add Qt-> Qt Designer interface type, select Widget template, change the name for the Test, at this time there is a ui file

3, code initializes

Add the header file in Test.h

#include <QtUiPlugin/QDesignerExportWidget>

In the class name preceded by QDESIGNER_WIDGET_EXPORT macro

4, open ui file, you want to design the interface

 

Here dragged three checkbox, function is also checked on a check 2,3, 2,3 1 does not tick tick

5, code implementation

Into the first checkbox in clik callback

void Test::on_checkBox_clicked()
{
    if(ui->checkBox->isChecked())
    {
        ui->checkBox_2->setChecked(true);
        ui->checkBox_3->setChecked(true);
    }
    else
    {
        ui->checkBox_2->setChecked(false);
        ui->checkBox_3->setChecked(false);
    }
}

6, compiled, generated in the corresponding folder and testplugin.lib testplugin.dll

7 to give the final document

testplugin.dll,

testplugin.lib,

test.h

 

How to use it?

1, placed under the testplugin.dll Qt library path, and path Creator

D:\Qt5.10.1\5.10.1\msvc2015\plugins\designer

D:\Qt5.10.1\Tools\QtCreator\bin\plugins\designer

2, using the corresponding version of the new construction Creator, you can see the controls ui With Test

 

3, to drag this control interface on ok

 

Guess you like

Origin www.cnblogs.com/judes/p/10993780.html