qtinuum / QtnProperty

Extended properties for Qt5
Apache License 2.0
425 stars 153 forks source link

string list and int list error :Cannot find delegate with name... #59

Open WangYG79 opened 1 month ago

WangYG79 commented 1 month ago

The code :

    // property set
    QtnPropertySet *propertyStr = new QtnPropertySet(m_propertySet);
    m_propertySet->addChildProperty(propertyStr);
    propertyStr->setName("string 3 style");

    // lineEdit ok
    auto strEdit = qtnCreateProperty<QtnPropertyQString>(propertyStr);
    strEdit->setName("title");
    strEdit->setValue("no title");

    // file ok
    auto strFile = qtnCreateProperty<QtnPropertyQString>(propertyStr);
    strFile->setName("select path");
    QtnPropertyDelegateInfo fileDeleg;
    fileDeleg.name = "File";
    fileDeleg.attributes["acceptMode"] = QFileDialog::AcceptOpen;
    fileDeleg.attributes["defaultSuffix"] = "Text File | *.txt";
    fileDeleg.attributes["fileMode"] = QFileDialog::ExistingFile;
    fileDeleg.attributes["options"] = QFileDialog::ExistingFile;
    fileDeleg.attributes["viewMode"] = QFileDialog::Detail;
    strFile->setDelegateInfo(fileDeleg);

    // list error
    auto strList = qtnCreateProperty<QtnPropertyQString>(propertyStr);
    strList->setName("Device Type");
    QtnPropertyDelegateInfo listDeleg;
    listDeleg.name = "List";
    listDeleg.attributes["items"] = QStringList() << "Single device" << "Net devicee" << "Other device";
    strList->setDelegateInfo(listDeleg);

    // intList error
    auto intValue3 = qtnCreateProperty<QtnPropertyInt>(propertyStr, "int_List");
    intValue3->setMaxValue(9);
    intValue3->setMinValue(0);
    intValue3->setValue(3);
    QList<int> IntList;
    for(int i = 0; i < 10; i++) {
        IntList.append(i);
    }
    QtnPropertyDelegateInfo intNewDeleg3("IntList");
    intNewDeleg3.attributes.insert("values", QVariant::fromValue(IntList));
    intValue3->setDelegateInfo(intNewDeleg3);

Two Error when running:

13:16:42: Starting E:\learn\qt\mytest\build-demo1-Desktop_Qt_5_15_2_MSVC2019_32bit-Debug\debug\demo1.exe...
Cannot find delegate with name "IntList" for property "int_List"
Did you forget to register "IntList" delegate for QtnPropertyInt type?
Cannot find delegate with name "List" for property "Device Type"
Did you forget to register "List" delegate for QtnPropertyQString type?

Can you tell me how to solve the 2 errors? Thanks a lot !