【解決方法】オブジェクト/クラスを変更するにはどうすればよいですか?


簡単なアドバイスを求める

C++ コードを再構築しています。
現在、QtCreator ビルドのデフォルトクラスがあります。
このクラスはライブラリを利用して「システムコール」を処理します。

どちらかのオプションを渡してクラスを再構築するのが好きです #
またはシステムコマンドの実際のテキスト。

何が好ましいでしょうか?

オプション # を渡して、デフォルトではなく新しいコンストラクターを使用すると思います
コマンドを pic (スイッチ) に…

コマンドは「文字列リスト」にすることができ、「スイッチ」は複雑になりすぎる可能性があります…

私が試したこと:

オプション # – int … を渡します。

元のデフォルトのコンストラクターは次のとおりです

C++
MainWindow_Bluewtoothctl_Dialog::MainWindow_Bluewtoothctl_Dialog(QWidget *parent)
    : QDialog(parent)
    , ui(new Ui::MainWindow_Bluewtoothctl_Dialog)
{
    ui->setupUi(this);

#ifdef TRACE
...
#endif
    //..text = " Constructor...";
    // ui->textEdit->append(" Constructor...");
}

実は
int オプションを「新しいコンストラクター」に渡すにはどうすればよいですか?

今のところ、これは次のようになります。

C++
// origninal default constructor
MainWindow_Bluewtoothctl_Dialog(QWidget *parent = nullptr);

解決策 1

デフォルトを持つパラメータの後に、デフォルトのないパラメータを追加することはできません。 したがって、次のようになります。

C++
// illegal as command has no default
MainWindow_Bluewtoothctl_Dialog(QWidget *parent = nullptr, QTstring command)

// needs to be ...
MainWindow_Bluewtoothctl_Dialog(QWidget *parent, QTstring command)

// or
MainWindow_Bluewtoothctl_Dialog(QWidget *parent = nullptr, QTstring command = 'whatever a null QTstring is')

コメント

タイトルとURLをコピーしました