Click here to Skip to main content
15,896,425 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Asking for simple advise

I am rebuilding my C++ code.
Currently I have QtCreator build default class.
The class processes "system call" using library.

I like to rebuild the class passing either option #
or actual text of the system command.

What would be preferred?

I think passing a option # and let new, not default, constructor
to pic (switch ) the command...

The commands can be "string list" and the "switch" could get too convoluted...

What I have tried:

Pass option # - int ....

Here is the original default constructor
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...");
}
Actually
how do I pass an int option to the "new constructor"?

As of now this looks this way:
C++
// origninal default constructor
MainWindow_Bluewtoothctl_Dialog(QWidget *parent = nullptr);
Posted
Updated 5-Jan-24 22:32pm
v2

After few trials I opted to pass an index to the class / object.
I can add the necessary text using QStringList and foreach loop...
either to class or as part of configuration library.
Thanks

case closed
 
Share this answer
 
Comments
RedDk 12-Jan-24 16:20pm    
Ha! "Case Closed" ... That's what the Fourth Doctor thought :)
You cannot add parameters without defaults after a parameter that does have a default. So the folowing:
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')
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900