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. QPdfView, QSerial port, Gstreamer issues
Qt 6.11 is out! See what's new in the release blog

QPdfView, QSerial port, Gstreamer issues

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 3 Posters 891 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.
  • D Offline
    D Offline
    ddddddxxx
    wrote on last edited by ddddddxxx
    #1

    Hello.
    I have been learning QT for a while and I have encountered few problems that I didn't manage to solve on my own. First is QPdfView header is no where to be found QTMaintainence tool shows that I have installed Qt Pdf library, I also have tried to reinstall it and search in QT folder with no success (QT version 6.5.2). Second problem is that when I create virtual com port pair, succesfully open one of the ports (according to QSerialPort::open) and write data to it I still don't get anything on the other end (Virtual serial port Driver indicates that the port was never opened). Third problem is that I'm not sure how to use gstreamer I belive code like that:

    int main(int argc, char *argv[])
    {
        QApplication a(argc, argv);
        MainWindow w;
        QMediaPlayer * player;
        player = new QMediaPlayer;
        player->setSource(QUrl("gst-pipeline: videotestsrc ! autovideosink"));
        //player->setSource(QUrl("C://Users//username//Downloads//1.mp4"));
        QVideoWidget *vid;
        vid = new QVideoWidget;
        player->setVideoOutput(vid);
        std::cout<<player->isPlaying()<<std::endl;
        vid->show();
        player->play();
        return a.exec();
    }
    

    should display same thing as gst-launch-1.0.exe videotestsrc ! autovideosink however all I can see in QT app is a black screen (I have also tried qtvideosink). I have installed GStreamer MSVC 64-bit (VS 2019, Release CRT) (runtime and devel) from thier website. Do I need to do some configuration to make it work? (gst-launch-1.0.exe videotestsrc ! autovideosink works fine from CMD)

    C 1 Reply Last reply
    0
    • D ddddddxxx

      Hello.
      I have been learning QT for a while and I have encountered few problems that I didn't manage to solve on my own. First is QPdfView header is no where to be found QTMaintainence tool shows that I have installed Qt Pdf library, I also have tried to reinstall it and search in QT folder with no success (QT version 6.5.2). Second problem is that when I create virtual com port pair, succesfully open one of the ports (according to QSerialPort::open) and write data to it I still don't get anything on the other end (Virtual serial port Driver indicates that the port was never opened). Third problem is that I'm not sure how to use gstreamer I belive code like that:

      int main(int argc, char *argv[])
      {
          QApplication a(argc, argv);
          MainWindow w;
          QMediaPlayer * player;
          player = new QMediaPlayer;
          player->setSource(QUrl("gst-pipeline: videotestsrc ! autovideosink"));
          //player->setSource(QUrl("C://Users//username//Downloads//1.mp4"));
          QVideoWidget *vid;
          vid = new QVideoWidget;
          player->setVideoOutput(vid);
          std::cout<<player->isPlaying()<<std::endl;
          vid->show();
          player->play();
          return a.exec();
      }
      

      should display same thing as gst-launch-1.0.exe videotestsrc ! autovideosink however all I can see in QT app is a black screen (I have also tried qtvideosink). I have installed GStreamer MSVC 64-bit (VS 2019, Release CRT) (runtime and devel) from thier website. Do I need to do some configuration to make it work? (gst-launch-1.0.exe videotestsrc ! autovideosink works fine from CMD)

      C Offline
      C Offline
      ChrisW67
      wrote on last edited by
      #2

      @ddddddxxx said in QPdfView, QSerial port, Gstreamer issues:

      First is QPdfView header is no where to be found QTMaintainence tool shows that I have installed Qt Pdf library, I also have tried to reinstall it and search in QT folder with no success (QT version 6.5.2).

      Certainly installed here with the same Qt 6.5.2 version (on Linux though) and a freshly installed "Qt Pdf" add-on

      chrisw@newton:~/Qt/6.5.2/gcc_64/include$ find . -name '*Pdf*' 
      ./QtPdfWidgets
      ./QtPdfWidgets/QtPdfWidgets
      ./QtPdfWidgets/QtPdfWidgetsDepends
      ./QtPdfWidgets/QPdfView
      ./QtPdfWidgets/6.5.2/QtPdfWidgets
      ./QtPdfWidgets/QtPdfWidgetsVersion
      ./QtPdf
      ./QtPdf/QPdfBookmarkModel
      ./QtPdf/QPdfDocumentRenderOptions
      ./QtPdf/QPdfDocument
      ./QtPdf/QPdfPageRenderer
      ./QtPdf/QPdfSearchModel
      ./QtPdf/QtPdfDepends
      ./QtPdf/QPdfLink
      ./QtPdf/QtPdf
      ./QtPdf/QPdfSelection
      ./QtPdf/QPdfPageNavigator
      ./QtPdf/6.5.2/QtPdf
      ./QtPdf/QtPdfVersion
      ./QtPdfQuick
      ./QtPdfQuick/QtPdfQuickVersion
      ./QtPdfQuick/QtPdfQuick
      ./QtPdfQuick/6.5.2/QtPdfQuick
      ./QtPdfQuick/QtPdfQuickDepends
      ./QtGui/QPdfWriter
      

      @ddddddxxx said in QPdfView, QSerial port, Gstreamer issues:

      Second problem is that when I create virtual com port pair, succesfully open one of the ports (according to QSerialPort::open) and write data to it I still don't get anything on the other end (Virtual serial port Driver indicates that the port was never opened).

      Cannot comment without seeing the code.

      D 1 Reply Last reply
      1
      • C ChrisW67

        @ddddddxxx said in QPdfView, QSerial port, Gstreamer issues:

        First is QPdfView header is no where to be found QTMaintainence tool shows that I have installed Qt Pdf library, I also have tried to reinstall it and search in QT folder with no success (QT version 6.5.2).

        Certainly installed here with the same Qt 6.5.2 version (on Linux though) and a freshly installed "Qt Pdf" add-on

        chrisw@newton:~/Qt/6.5.2/gcc_64/include$ find . -name '*Pdf*' 
        ./QtPdfWidgets
        ./QtPdfWidgets/QtPdfWidgets
        ./QtPdfWidgets/QtPdfWidgetsDepends
        ./QtPdfWidgets/QPdfView
        ./QtPdfWidgets/6.5.2/QtPdfWidgets
        ./QtPdfWidgets/QtPdfWidgetsVersion
        ./QtPdf
        ./QtPdf/QPdfBookmarkModel
        ./QtPdf/QPdfDocumentRenderOptions
        ./QtPdf/QPdfDocument
        ./QtPdf/QPdfPageRenderer
        ./QtPdf/QPdfSearchModel
        ./QtPdf/QtPdfDepends
        ./QtPdf/QPdfLink
        ./QtPdf/QtPdf
        ./QtPdf/QPdfSelection
        ./QtPdf/QPdfPageNavigator
        ./QtPdf/6.5.2/QtPdf
        ./QtPdf/QtPdfVersion
        ./QtPdfQuick
        ./QtPdfQuick/QtPdfQuickVersion
        ./QtPdfQuick/QtPdfQuick
        ./QtPdfQuick/6.5.2/QtPdfQuick
        ./QtPdfQuick/QtPdfQuickDepends
        ./QtGui/QPdfWriter
        

        @ddddddxxx said in QPdfView, QSerial port, Gstreamer issues:

        Second problem is that when I create virtual com port pair, succesfully open one of the ports (according to QSerialPort::open) and write data to it I still don't get anything on the other end (Virtual serial port Driver indicates that the port was never opened).

        Cannot comment without seeing the code.

        D Offline
        D Offline
        ddddddxxx
        wrote on last edited by ddddddxxx
        #3

        @ChrisW67 said in QPdfView, QSerial port, Gstreamer issues:

        QPdfView

        I have just found QPdfView in msvc2019_64 (I was using and searching in mingw_64) so I guess this one is solved.
        Port com code looks something like that:

        this->serialPorts = QSerialPortInfo::availablePorts();
        
        for (QSerialPortInfo &portInfo : serialPorts) {
                    if(currentIndex == 0)
                        curr_port_info = portInfo;
                    currentIndex--;
        
         }
        
            QSerialPort port_com(curr_port_info);
            port_com.setPortName(curr_port_info.portName());
            port_com.setBaudRate(QSerialPort::BaudRate::Baud9600);
            port_com.setParity(QSerialPort::Parity::EvenParity);
            port_com.setFlowControl(QSerialPort::FlowControl::NoFlowControl);
            port_com.setDataBits(QSerialPort::DataBits::Data8);
            port_com.setStopBits(QSerialPort::StopBits::OneStop);
            
        
            if(port_com.open(QIODeviceBase::ReadWrite))
                port_com.write(file);
        
        

        btw port_com.write(file); returns correct file size and of course if i try to open port that is already opened by tera term or putty port_com.open() returns -1

        SGaistS 1 Reply Last reply
        0
        • D ddddddxxx

          @ChrisW67 said in QPdfView, QSerial port, Gstreamer issues:

          QPdfView

          I have just found QPdfView in msvc2019_64 (I was using and searching in mingw_64) so I guess this one is solved.
          Port com code looks something like that:

          this->serialPorts = QSerialPortInfo::availablePorts();
          
          for (QSerialPortInfo &portInfo : serialPorts) {
                      if(currentIndex == 0)
                          curr_port_info = portInfo;
                      currentIndex--;
          
           }
          
              QSerialPort port_com(curr_port_info);
              port_com.setPortName(curr_port_info.portName());
              port_com.setBaudRate(QSerialPort::BaudRate::Baud9600);
              port_com.setParity(QSerialPort::Parity::EvenParity);
              port_com.setFlowControl(QSerialPort::FlowControl::NoFlowControl);
              port_com.setDataBits(QSerialPort::DataBits::Data8);
              port_com.setStopBits(QSerialPort::StopBits::OneStop);
              
          
              if(port_com.open(QIODeviceBase::ReadWrite))
                  port_com.write(file);
          
          

          btw port_com.write(file); returns correct file size and of course if i try to open port that is already opened by tera term or putty port_com.open() returns -1

          SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi,

          Might be a silly question but: are you sure you are writing to the com port your device is attached to ? From your code, there's no way to know.

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

          D 1 Reply Last reply
          0
          • SGaistS SGaist

            Hi,

            Might be a silly question but: are you sure you are writing to the com port your device is attached to ? From your code, there's no way to know.

            D Offline
            D Offline
            ddddddxxx
            wrote on last edited by ddddddxxx
            #5

            @SGaist
            Yes I'm quite confident that I'm writing to the desired port as portName() seems to be correct and as I said if I try to open port that is already opened by putty for example then QT open() returns false I also have tried opening and sending to all ports in QSerialPortInfo::availablePorts(); with no success. Oh, and there is no physical device as I don't have any I'm just making a pair of virtual ports, open one with tera term or putty and then I'm trying to open the other one and send data with QT so I will receive the data on real term/putty end. (if I use tera term/putty on boths ports connection works fine)

            PS. I also have tried to use other software to create virtual ports.

            SGaistS 1 Reply Last reply
            0
            • D ddddddxxx

              @SGaist
              Yes I'm quite confident that I'm writing to the desired port as portName() seems to be correct and as I said if I try to open port that is already opened by putty for example then QT open() returns false I also have tried opening and sending to all ports in QSerialPortInfo::availablePorts(); with no success. Oh, and there is no physical device as I don't have any I'm just making a pair of virtual ports, open one with tera term or putty and then I'm trying to open the other one and send data with QT so I will receive the data on real term/putty end. (if I use tera term/putty on boths ports connection works fine)

              PS. I also have tried to use other software to create virtual ports.

              SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              As an additional measure, you should also add handling of the errorOccured signal.

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

              D 1 Reply Last reply
              0
              • SGaistS SGaist

                As an additional measure, you should also add handling of the errorOccured signal.

                D Offline
                D Offline
                ddddddxxx
                wrote on last edited by ddddddxxx
                #7

                @SGaist
                errorOccured showed QSerialPort::NoError. However I have managed to solve my problem. Probably if I would have given you full context you would manage to help me earlier as problem was that initialization of QSerialPort port_com(curr_port_info); was inside of a slot function and it turns out that if you close port before that function finishes no data will be sent. However I don't know why is that.

                C 1 Reply Last reply
                0
                • D ddddddxxx

                  @SGaist
                  errorOccured showed QSerialPort::NoError. However I have managed to solve my problem. Probably if I would have given you full context you would manage to help me earlier as problem was that initialization of QSerialPort port_com(curr_port_info); was inside of a slot function and it turns out that if you close port before that function finishes no data will be sent. However I don't know why is that.

                  C Offline
                  C Offline
                  ChrisW67
                  wrote on last edited by ChrisW67
                  #8

                  @ddddddxxx said in QPdfView, QSerial port, Gstreamer issues:

                  turns out that if you close port before that function finishes no data will be sent. However I don't know why is that.

                  If all that code was inside a slot then the QSerialPort object is destroyed at the end of the slot execution (current scope of object).

                  QSerialPort, or any of the QIODevice sub-classes, will not actually send or receive data until your code enters the Qt event loop. This happens when the slot exits but by that time your object is no more.

                  1 Reply Last reply
                  2

                  • Login

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