Results 1 to 3 of 3

Thread: Sane sample app gives different results on pseudo QT terminal and on gnome-terminal

  1. #1
    Join Date
    Feb 2012
    Posts
    4
    Qt products
    Qt3 Qt4 Qt/Embedded Qt Jambi PyQt3 PyQt4
    Platforms
    Unix/X11 Windows

    Default Sane sample app gives different results on pseudo QT terminal and on gnome-terminal

    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
    Attached Files Attached Files

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Sane sample app gives different results on pseudo QT terminal and on gnome-termin

    Same executable plus same environment == same behaviour.

    Since we are talking about the same executable, I think you will find that the environment you have configured your Qt Creator project to provide to your running project is different from the default environment in your gnome-terminal. Different library paths, environment variables SANE_*, picking up a different run time copy of libsane etc.

    Try setting SANE_DLL_DEBUG=128 in the environment to see if obvious errors arise.

  3. #3
    Join Date
    Feb 2012
    Posts
    4
    Qt products
    Qt3 Qt4 Qt/Embedded Qt Jambi PyQt3 PyQt4
    Platforms
    Unix/X11 Windows

    Default Re: Sane sample app gives different results on pseudo QT terminal and on gnome-termin

    Thank you a lot. Resolved the issue.

Similar Threads

  1. is it possible the qdebug in terminal??
    By iswaryasenthilkumar in forum Newbie
    Replies: 2
    Last Post: 12th May 2015, 08:59
  2. Output to terminal
    By wookie1 in forum Newbie
    Replies: 5
    Last Post: 12th June 2012, 15:22
  3. QT to linux terminal
    By Zexix in forum Qt Programming
    Replies: 2
    Last Post: 5th March 2012, 19:18
  4. terminal widget
    By kernel_panic in forum Qt Programming
    Replies: 11
    Last Post: 21st November 2009, 15:08
  5. Looking for widget to run terminal app
    By marcell in forum Qt Programming
    Replies: 0
    Last Post: 16th May 2008, 17:24

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.