Hi All,
I wrote sample code that uses sane library to communicate with my scanner.
//#include <QCoreApplication>
#include <iostream>
#include <sane/sane.h>
#include <stdio.h>
using namespace std;
int sane_backend_versioncode;
const SANE_Device **devlist=NULL;
int num_of_devs;
int main(int argc, char *argv[])
{
sane_init(&sane_backend_versioncode, NULL);
sane_get_devices(&devlist, SANE_FALSE );
for (num_of_devs = 0; devlist[num_of_devs]; ++num_of_devs);
if (num_of_devs > 0) /* devices available */
{
std::cout << "Number of scan devices is " << num_of_devs <<".\n";
}
else
{
std::cout << "Number of scan devices is 0";
}
sane_exit();
cout << "" << endl; // prints
return 0;
}
What I get from Qt Creator is surprising. On its pseudo terminal I get message "Number of scan devices is 0" however when I execute the same compiled binary from gnome-terminal I get that "Number of scan devices is 1". When I created similar project in eclipse I got the same result "Number of scan devices is 1" on its pseudoterminal. Moreover when I set in Qt Creator to launch the compiled app in gnome-terminal I still have the result "Number of scan devices is 0". This was double checked and there is no space for my error.
Do you know what is going on? When Qt creator launches app it returns almost immediately with result "Number of scan devices is 0". When "Number of scan devices is 1" is returned it is after couple of seconds so after expected scanning. The result of 0 detected devices is in release and debug binary.
I attached my qt sample app with the above code. I think that it a fault of Qt pseudo terminal. Maybe it disables something that shouldn't be.
I get that result on Ubuntu 14.04 64bit and USB connected scanner Epson Stylus CX3650. On Qt creator 5.3.1 and 5.5.1.
Thanks,
Marcin
Bookmarks