Simple program that opens a GUI, you click one button to set curDir, click another button to set savDir, and a third button does some C++ code similar to
ls -l curDir > savDir.txt
One of my Qt functions:
void dirList::on_savBut_clicked(){
savDir = QFileDialog::getExistingDirectory(
this,"Save Location",QDir::homePath());
savPath = savDir.absolutePath();
ui->savText->setText(savPath);
}
On the savDir = QFileDialog::getExistingDirectory(... line I get a warning:
'operator=' is depreciated: Use QDir::setPath() instead
Could anyone give an example how I might incorporate setPath()?
You can simply write
savPath = QFileDialog::getExistingDirectory(
this,"Save Location",QDir::homePath());
Without using savDir.
I believe setPath is just a drop in replacement instead of using assignment for when updating a QDir with a QString path.
savDir = QFileDialog::getExistingDirectory(
this,"Save Location",QDir::homePath());
simply becomes
savDir.setPath(QFileDialog::getExistingDirectory(
this,"Save Location",QDir::homePath()));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With