Seite 1 von 1

QCommandLineOption Array ?

Verfasst: 22. Januar 2015 10:22
von huckleberry
Hallo,

ich versuche ein QCommandLineOption Array anzulegen. Ich möchte dann später nur ein Zeiger auf das erste Element übergeben.

Code: Alles auswählen

    QCommandLineOption options[] = QCommandLineOption()[5];
    options[0] = average_opt;
    options[1] = time_comp_opt;
    options[2] = duration_opt;
    options[3] = query_number_opt;
    options[4] = out_opt;
Es kommt nachvollziehbar:
Fehler: no matching function for call to 'QCommandLineOption::QCommandLineOption()' QCommandLineOption options[] = QCommandLineOption()[5];
Das QCommandLineOption hat keinen leeren Konstruktor, es wird mindestens ein QString als NAme verlangt. Aber die R-Value QCoomandLineOptions haben ja bereits ein Namen..
Soll ich irgendeinen String angeben, oder gibts was elegantes?

Thnx im voraus und VG
Huck

Re: QCommandLineOption Array ?

Verfasst: 22. Januar 2015 11:07
von huckleberry
Sogar Zeiger auf Zeiger schlägt fehl:

Code: Alles auswählen

    QCommandLineOption * out_opt = new QCommandLineOption(QStringList() << "o" << "output", /// .... usw
    // alle R-Value Options unten wurden wie oben per new erzeugt.
    QCommandLineOption *options[5]; // wie **options
    *options[0] = average_opt;
    *options[1] = time_comp_opt;
    *options[2] = duration_opt;
    *options[3] = query_number_opt;
    *options[4] = out_opt;
Fehler: no match for 'operator=' (operand types are 'QCommandLineOption' and 'QCommandLineOption*') *options[0] = average_opt;

Re: QCommandLineOption Array ?

Verfasst: 22. Januar 2015 19:02
von veeman
Nimm dafür lieber das:

Code: Alles auswählen

QList<QCommandLineOption> optList;