c++ - QT error conversion non-scalar type error -
i catching output of qprocess , matching qregularexpression, gives error....
any hints??
/home/kshk/qt5/kshk-test1/main.cpp:33: error: conversion 'std::string {aka std::basic_string<char>}' non-scalar type 'qregularexpressionmatch' requested qregularexpressionmatch match = output.tostdstring(); ^ this code....
#include <qcoreapplication> #include <qprocess> #include <iostream> #include <qregularexpression> #include <qregularexpressionmatch> #include <qregularexpressionmatchiterator> #include <qdebug> using namespace std; int main(int argc, char *argv[]) { qcoreapplication a(argc, argv); qstring command = "bash -c \"netstat -i | grep ens33 | awk \'{print $3}\'\""; cout << "hello qt!" << endl; qprocess process; process.start(command); process.waitforfinished(); qstring output = process.readallstandardoutput(); //qdebug << output; cout << output.tostdstring() << endl; qregularexpression re("\\d\\d\\d\\d \\w\\w"); //qregularexpressionmatch match = re.match("this string - string 1234 normalyy write everyday - pattern"); //qregularexpressionmatch match = re.match("this 1234 al"); qregularexpressionmatch match = output.tostdstring(); if (match.hasmatch()){ qstring result = match.captured(0); cout << result.tostdstring() << endl; cout << "string matched" << endl; } homecoming a.exec(); } c++ qt
No comments:
Post a Comment