Created
April 7, 2016 06:43
-
-
Save jniemann66/8ad5c55d19bf8b8660c4e7b4ab7e7d4a to your computer and use it in GitHub Desktop.
Qt: populating QCombox items using std output from external process
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Launch external process, and populate QComboBox using output from the process: | |
void MainWindow::PopulateBitFormats(const QString& fileName) | |
{ | |
QProcess ConverterQuery; | |
ui->BitDepthCombo->clear(); | |
int extidx = fileName.lastIndexOf("."); | |
if(extidx > -1){ | |
QString ext = fileName.right(fileName.length()-extidx-1); // get file extension from filename | |
ConverterQuery.start(ConverterPath, QStringList() << "--listsubformats" << ext); // ask converter for a list of subformats for the given file extension | |
if (!ConverterQuery.waitForFinished()) | |
return; | |
ConverterQuery.setReadChannel(QProcess::StandardOutput); | |
while(ConverterQuery.canReadLine()){ | |
QString line = QString::fromLocal8Bit(ConverterQuery.readLine()); | |
ui->BitDepthCombo->addItem(line.simplified()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment