Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QProcess and scanimage (Linux)
Forum Updated to NodeBB v4.3 + New Features

QProcess and scanimage (Linux)

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 1.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • cvitaglianoC Offline
    cvitaglianoC Offline
    cvitagliano
    wrote on last edited by
    #1

    I'm trying to make the QProcess class work with the linux scanimage application to scan documents that are on paper.

    My scanner is a Canon CanoScan.

    I have tried several ways, but the QProcess START statement does that it works, but it does not trigger the scanner.

    Anyone have any tips?

    void ClasseScanner :: on_pbScanDOC_clicked () {
       QString tipo_os = QSysInfo :: productType ();

    QString file_folder = QStandardPaths :: writableLocation (QStandardPaths :: AppConfigLocation);
       folder_file.append ("/ docto_scan.tif");

    QString command = "scanimage -l 0 -t 0 -x 90 -and 220 -mode Color --resolution 150 --rightness 0 --contrast 0 --format = tiff>";
       command.append (file_file);

    if (type_us.pare ("ubuntu") == 0) {
         process = new QProcess (this);
         process-> start (command);

    if (! process-> waitForFinished (-1)) qDebug () << "Failed:" << process-> errorString ();
         else qDebug () << "OK" << process-> readAll ();
       }
    }

    JonBJ 1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Please build the argument list like shown in the QProcess documentation.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2
      • cvitaglianoC cvitagliano

        I'm trying to make the QProcess class work with the linux scanimage application to scan documents that are on paper.

        My scanner is a Canon CanoScan.

        I have tried several ways, but the QProcess START statement does that it works, but it does not trigger the scanner.

        Anyone have any tips?

        void ClasseScanner :: on_pbScanDOC_clicked () {
           QString tipo_os = QSysInfo :: productType ();

        QString file_folder = QStandardPaths :: writableLocation (QStandardPaths :: AppConfigLocation);
           folder_file.append ("/ docto_scan.tif");

        QString command = "scanimage -l 0 -t 0 -x 90 -and 220 -mode Color --resolution 150 --rightness 0 --contrast 0 --format = tiff>";
           command.append (file_file);

        if (type_us.pare ("ubuntu") == 0) {
             process = new QProcess (this);
             process-> start (command);

        if (! process-> waitForFinished (-1)) qDebug () << "Failed:" << process-> errorString ();
             else qDebug () << "OK" << process-> readAll ();
           }
        }

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by JonB
        #3

        @cvitagliano said in QProcess and scanimage (Linux):

        QString command = "scanimage -l 0 -t 0 -x 90 -and 220 -mode Color --resolution 150 --rightness 0 --contrast 0 --format = tiff>";    command.append (file_file);

        If I read you right, your command is using the > output redirection symbol right at the end, to send output to a file? You won't be able to do that if you execute a QProcess with scanimage as the executable.

        You will need either to send the whole string for execution to /bin/sh or /bin/bash so that the shell interprets and acts on the > for you, or you could use http://doc.qt.io/qt-5/qprocess.html#setStandardOutputFile to set up the output file yourself from the calling program instead.

        cvitaglianoC 1 Reply Last reply
        2
        • JonBJ JonB

          @cvitagliano said in QProcess and scanimage (Linux):

          QString command = "scanimage -l 0 -t 0 -x 90 -and 220 -mode Color --resolution 150 --rightness 0 --contrast 0 --format = tiff>";    command.append (file_file);

          If I read you right, your command is using the > output redirection symbol right at the end, to send output to a file? You won't be able to do that if you execute a QProcess with scanimage as the executable.

          You will need either to send the whole string for execution to /bin/sh or /bin/bash so that the shell interprets and acts on the > for you, or you could use http://doc.qt.io/qt-5/qprocess.html#setStandardOutputFile to set up the output file yourself from the calling program instead.

          cvitaglianoC Offline
          cvitaglianoC Offline
          cvitagliano
          wrote on last edited by
          #4

          @JonB Thank you very much. The two alternatives worked perfectly.

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved