For example, add a second parameter in VerticalBox constructor:
VerticalBox
( const QString
& fileName
= QString(),
QWidget * parent
= NULL )
VerticalBox( const QString& fileName = QString(), QWidget * parent = NULL )
To copy to clipboard, switch view to plain text mode
And use it to setup lineEdit in constructor:
VerticalBox
::VerticalBox(const QString
& fileName,
QWidget *parent
) : QWidget(parent
){
//HBox contentBox containing the QLabel and QLineEdit:
name_in->setText(fileName);
contentBox->addWidget(name);
contentBox->addWidget(name_in);
...
VerticalBox::VerticalBox(const QString& fileName,QWidget *parent) : QWidget(parent)
{
QVBoxLayout *vbox = new QVBoxLayout(this);
QHBoxLayout *contentBox = new QHBoxLayout();
QHBoxLayout *buttonBox = new QHBoxLayout();
//HBox contentBox containing the QLabel and QLineEdit:
QLabel *name = new QLabel("Name: ", this);
QLineEdit *name_in = new QLineEdit(this);
name_in->setText(fileName);
contentBox->addWidget(name);
contentBox->addWidget(name_in);
...
To copy to clipboard, switch view to plain text mode
In order to pass the "fileName" argument you can use argv array:
...
VerticalBox window( toPass );
...
QApplication app(argc, argv);
const QString toPass = argc > 1 ? QString(argv[1]) : QString();
VerticalBox window( toPass );
To copy to clipboard, switch view to plain text mode
argv[0] is usually name of the program, argv[1], argv[2], ... are parameters passed.
You can also use QCoreApplication::arguments()
Bookmarks