QPdfView, QSerial port, Gstreamer issues
-
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)
-
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)
@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.
-
@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.
@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
-
@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
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.
-
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.
@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.
-
@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.
As an additional measure, you should also add handling of the errorOccured signal.
-
As an additional measure, you should also add handling of the errorOccured signal.
@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. -
@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.@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.