Solved listing available devices in ComboBox
-
Re: Get the list of available audio devices in Linux
Hi,
I want to display the devices listed under /dev/ttyACM* as the ComboBox inputs.
Can we make this output as a input to the ComboBox? and How?Please guide me on this!
Thanks in advance!!
Regards,
Kripashree -
@kripashree said in listing available devices in ComboBox:
Can we make this output as a input to the ComboBox? and How?
comboBox->addItems( QDir("/dev/ttyACM").entryList() );
-
Hi Raven,
It is not displaying any combobox options!! now combobox is empty after adding your code!!
Regards,
Kripashree -
comboBox->addItems( QDir("/dev").entryList().filter("/dev/ttyACM");
-
@jsulm I have the strange feeling it does not work because the
tty*
entries are no regular files, but character devices. For me, evenQDir("/dev").entryList();
only gives the subdirectories, not the devices itself. -
This also not working!! combobox is empty!!
-
@aha_1980 I don't have a linux system here to test, but is that also the case, if you specify
QDir::AllEntries
andQDir::Hidden
andQDir::System
as filters ?Especially
System
seems to be important:List system files (on Unix, FIFOs, sockets and device files are included...)
-
@J.Hilk said in listing available devices in ComboBox:
QDir::System
Thanks, that helped :)
The following code shows all
tty
devices on my Ubuntu system:#include <QDir> #include <QDebug> int main(int argc, char *argv[]) { const QStringList entries = QDir("/dev").entryList(QDir::System).filter("tty"); qDebug() << entries; }
Output:
10:16:37: Starting DirEntryList... ("tty", "tty0", "tty1", "tty10", "tty11", "tty12", "tty13", "tty14", "tty15", "tty16", "tty17", "tty18", "tty19", "tty2", "tty20", "tty21", "tty22", "tty23", "tty24", "tty25", "tty26", "tty27", "tty28", "tty29", "tty3", "tty30", "tty31", "tty32", "tty33", "tty34", "tty35", "tty36", "tty37", "tty38", "tty39", "tty4", "tty40", "tty41", "tty42", "tty43", "tty44", "tty45", "tty46", "tty47", "tty48", "tty49", "tty5", "tty50", "tty51", "tty52", "tty53", "tty54", "tty55", "tty56", "tty57", "tty58", "tty59", "tty6", "tty60", "tty61", "tty62", "tty63", "tty7", "tty8", "tty9", "ttyprintk", "ttyS0", "ttyS1", "ttyS10", "ttyS11", "ttyS12", "ttyS13", "ttyS14", "ttyS15", "ttyS16", "ttyS17", "ttyS18", "ttyS19", "ttyS2", "ttyS20", "ttyS21", "ttyS22", "ttyS23", "ttyS24", "ttyS25", "ttyS26", "ttyS27", "ttyS28", "ttyS29", "ttyS3", "ttyS30", "ttyS31", "ttyS4", "ttyS5", "ttyS6", "ttyS7", "ttyS8", "ttyS9") 10:16:37: DirEntryList exited with code 0
Porting that to a
QComboBox
should be easy... -
@jsulm Thank you.
comboBox->addItems( QDir("/dev").entryList().filter("/dev/ttyACM"); This is helped.
-
@kripashree then please mark this topic as SOLVED. Thanks