QCommandLineOption Array ?

Alles rund um die Programmierung mit Qt
Antworten
huckleberry
Beiträge: 115
Registriert: 2. Oktober 2010 17:07

QCommandLineOption Array ?

Beitrag 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
huckleberry
Beiträge: 115
Registriert: 2. Oktober 2010 17:07

Re: QCommandLineOption Array ?

Beitrag 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;
veeman
Beiträge: 280
Registriert: 3. Oktober 2012 01:43
Kontaktdaten:

Re: QCommandLineOption Array ?

Beitrag von veeman »

Nimm dafür lieber das:

Code: Alles auswählen

QList<QCommandLineOption> optList;
Antworten