How to promote a custom widget in QT Creator

前端 未结 2 1840
没有蜡笔的小新
没有蜡笔的小新 2021-01-13 07:13

In qt 5.2.1 I\'ve created some custom widgets, like a button. Traditionally there\'s two ways of doing this. You can either promote an existing widget. And change/add functi

2条回答
  •  清歌不尽
    2021-01-13 07:40

    This seems to be a bug in Qt Creator. A workaround, oddly enough is to add widgets twice to the list of widgets a widget library exports:

    IOSwidgets::IOSwidgets(QObject *parent)
        : QObject(parent)
    {
    
        m_widgets.append(new aircraftAttitudePlugin(this));
        m_widgets.append(m_widgets.last());
        m_widgets.append(new alfabeticKeypadPlugin(this));
        m_widgets.append(m_widgets.last());
        m_widgets.append(new arrowedFramePlugin(this));
        m_widgets.append(m_widgets.last());
        m_widgets.append(new buttonWidgetPlugin(this));
        m_widgets.append(m_widgets.last());
        m_widgets.append(new dataButtonPlugin(this));
        m_widgets.append(m_widgets.last());
        m_widgets.append(new frameWidgetPlugin(this));
        m_widgets.append(m_widgets.last());
        m_widgets.append(new headingDialPlugin(this));
        m_widgets.append(m_widgets.last());
        m_widgets.append(new imageWidgetPlugin(this));
        m_widgets.append(m_widgets.last());
        m_widgets.append(new labelWidgetPlugin(this));
        m_widgets.append(m_widgets.last());
        m_widgets.append(new linkedButtonWidgetPlugin(this));
        m_widgets.append(m_widgets.last());
        m_widgets.append(new linkedLabelWidgetPlugin(this));
        m_widgets.append(m_widgets.last());
        m_widgets.append(new linkedSliderWidgetPlugin(this));
        m_widgets.append(m_widgets.last());
        m_widgets.append(new NavButtonPlugin(this));
        m_widgets.append(m_widgets.last());
        m_widgets.append(new numericKeypadPlugin(this));
        m_widgets.append(m_widgets.last());
        m_widgets.append(new repositionWidgetPlugin(this));
        m_widgets.append(m_widgets.last());
        m_widgets.append(new runwayInformationPlugin(this));
        m_widgets.append(m_widgets.last());
        m_widgets.append(new slewWidgetPlugin(this));
        m_widgets.append(m_widgets.last());
        m_widgets.append(new sliderWidgetPlugin(this));
        m_widgets.append(m_widgets.last());
        m_widgets.append(new WeightBalancePlugin(this));
        m_widgets.append(m_widgets.last());
        m_widgets.append(new WindshearMicroburstLateralPlugin(this));
        m_widgets.append(m_widgets.last());
    }
    

    Hope this saves the next person who runs into this problem, the painstaking effort and the huge amount of time it took me to find this out:).

提交回复
热议问题