OK, thanks for the code. I did not make many changes to it except to change the Qt::StringLiterals to ordinary strings since I am using Qt 5 and this is not supported. I also found I needed to add QDESIGNER_EXPORT_WIDGETS in the project settings when building the plugin. (Led_6_0_1 -> Properties -> C/C++ -> Preprocessor -> Preprocessor Definitions).
I designed a simple dialog widget to test the LED widget. The dialog has 5 LED widgets, with different properties set in Qt Designer. There are three push buttons. The first (Toggle LEDs) changes the on / off state for each LED. The second (Change Shapes) sets a new shape for each LED using the setShape() property. The third button (Change Colors) sets new on / off colors for each LED using setOnColor() and setOffColor(). These changes are implemented using a set of simple QLists whose contents are rotated with each click.
The test program demonstrates that setting shape, color, and value properties works both in Qt Designer (with correct values in the .ui file) and at run-time.
TestLed.png
I have attached a ZIP file with the code. I did not include the VS project files since those were changed for Qt 5 and won't apply for you and Qt 6. Just copy the source files. The test project needs to link with your plugin .lib file and include Qt core, gui, widgets, and svg in the configuration settings. The plugin .dll file must be in your path or where the program can load it at runtime.
Led.zip
It is probably not correct to have the code for the LED widget inside of the Qt Designer plugin itself. This means any application you write has to link to the plugin library. That is not right. You should separate the code for the widget from the code for the plugin, and create a LED DLL and a plugin DLL. The plugin DLL is linked to the LED library, and you must put the LED DLL where Qt Designer can find it. When you write an application, you should be linking only to the LED .lib and installing the LED DLL with your application.




Reply With Quote

Bookmarks