0

我的标题中有以下代码:

StripChartConfiguration(
    uint32_t tmpStripChartFrameworkWidgetWidth,
    uint32_t tmpStripChartFrameworkWidgetHeight,
    QString tmpMissionName,
    QList<QString> tmpCommandandToneNameQList,
    QList<QString> mToneNameQList,
    FTSProtocolType tmpMissionProtocol,
    float_t mStripHeightInPixels,
    float_t tmpTimeSliceWidth,
    uint32_t tmpTimeframeInSecondsPerStrip,
    QColor tmpStripChartGLViewportBackgroundColor
        = QColor(Qt::lightGray),
    QColor tmpDefaultStateSliceColor 
        = QColor(Qt::lightGray),
    QColor tmpCommandedStateSliceColor
        = QColor(Qt::darkBlue),
    QColor tmpRequestedStateSliceColor
        = QColor(Qt::darkMagenta),
    QColor tmpRequestedConfirmedStateSliceColor
        = QColor(Qt::darkGreen),
    QColor tmpConfirmedDefaultStateSliceColor
        = QColor(Qt::darkYellow),       
    QColor tmpSuspendedDefaultStateSliceColor
        = QColor(0x82B384), //Stale Green
    QColor tmpCarrierDefaultStateSliceColor
        = QColor(Qt::lightGray),
    QColor tmpCarrierCommandedStateSliceColor
        = QColor(Qt::blue),
    QColor tmpCarrierRequestedStateSliceColor
        = QColor(Qt::magenta),
    QColor tmpCarrierRequestedConfirmedStateSliceColor
        = QColor(Qt::green),
    QColor tmpCarrierConfirmedDefaultStateSliceColor
        = QColor(Qt::yellow),
    QColor tmpCarrierSuspendedDefaultStateSliceColor
        = QColor(0x82B384)); //Stale Green

现在我想实例化这种类型的对象而不必指定颜色。所以从我的驱动程序我做:

uint32_t mFWWidth = 800;
uint32_t mFWHeight = 600;
QString mMissionName("This Is A Mission");
QList<QString> mCommandNameList;
for (uint32_t i = 0; i < 10; ++i) {
    mCommandNameList.push_back(QString("Command"));
}
QList<QString> mToneNameList;
for (uint32_t i = 0; i < 6; ++i) {
    mToneNameList.push_back(QString("Tone"));
}
StripChartConfiguration::FTSProtocolType mSCCFTSProtocol =   
    StripChartConfiguration::Irig;
float_t mStripHeightInPixels = 10;
float_t mTimeSliceWidthInPixels = 10;
uint32_t mTimeframeInSecondsPerStrip = 15;
/*
 * End of list of configuration for strip chart
 */
StripChartConfiguration mSCCC(mFWWidth, mFWHeight,        
    mMissionName, mCommandNameList, mToneNameList,
    mSCCFTSProtocol, mStripHeightInPixels, 
    mTimeframeInSecondsPerStrip);

但是 g++ 抱怨我缺少论点。我错过了什么?

mehoggan@mehoggan:~/Dev/StripChart$ make

g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I/opt/QtSDK/Desktop/Qt/474/gcc/mkspecs/default -I. -I/opt/QtSDK/Desktop/Qt/474/gcc/include/QtCore -I/opt/QtSDK/Desktop/Qt/474/gcc/include/QtGui -I/opt/QtSDK/Desktop/Qt/474/gcc/include/QtOpenGL -I/opt/QtSDK/Desktop/Qt/474/gcc/include -I/usr/X11R6/include -I. -o main.o main.cpp
main.cpp: In function ‘int main(int, char**)’:
main.cpp:39:36: error: no matching function for call to ‘StripChartConfiguration::StripChartConfiguration(uint32_t&, uint32_t&, QString&, QList<QString>&, QList<QString>&, StripChartConfiguration::FTSProtocolType&, float_t&, uint32_t&)’
main.cpp:39:36: note: candidates are:
stripchartconfiguration.h:84:5: note: StripChartConfiguration::StripChartConfiguration(const StripChartConfiguration&)
stripchartconfiguration.h:84:5: note:   candidate expects 1 argument, 8 provided
stripchartconfiguration.h:47:5: note: StripChartConfiguration::StripChartConfiguration(uint32_t, uint32_t, QString, QList<QString>, QList<QString>, StripChartConfiguration::FTSProtocolType, float_t, float_t, uint32_t, QColor, QColor, QColor, QColor, QColor, QColor, QColor, QColor, QColor, QColor, QColor, QColor, QColor)
stripchartconfiguration.h:47:5: note:   candidate expects 22 arguments, 8 provided
main.cpp:31:13: warning: unused variable ‘mTimeSliceWidthInPixels’ [-Wunused-variable]
make: *** [main.o] Error 1
4

1 回答 1

1

您正在通过..., float_t&, uint32_t&),并且..., float_t, float_t, uint32_t是预期的。您只是缺少一个浮点值。

请注意,您的代码风格看起来很糟糕。您不应该创建具有这么多参数的构造函数和方法。很容易错过其中之一。显然它已经发生了。单独分配每个字段会更加清晰和安全。

于 2012-06-13T23:41:06.443 回答