I found that no setLabel method is provided in QWidget, so how can I use the `label` in KConfig and QWidget?
Not quite clear what you are looking for.
If you want to associate a string with a widget, e.g. for debugging purposes, then you can do that with QObject::setObjectName()
If you want to associate a text field with an input widget then you can use QLabel or consider using QFormLayout if you have an input form with multiple entries.
And kconfig can have definitions for a configuration file fields, including labels for them: Using KConfig XT | Developer
An entry in KConfig can have label, but I just couldn’t find way to show it in QWidget. Tried a QLabel with a QCheckBox but it seems that QLabel can’t be handled. Will try QFormLayout later, thanks.
I can recommend you to have a look at existing source code, this is a great reference.
Like:
I just saw the code in KConfigDialogManager, it seems that the label in an entry is ignored in setupWidget.
But if I still want to get the label as a (Placeholder)Text (which I wanted to), I can get it through KConfigSkeletonGenericItem. If there’s an option that one can use label as (Placeholder)Text, it might be more convenient.
I guess it hasn’t been implemented (yet).
KConfigDialogManageris much newer than KconfigXT and label weren’t that used so its support wasn’t added.