Navigation

    Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Search
    • Unsolved
    1. Home
    2. Tags
    3. qbytearray
    Log in to post

    • UNSOLVED QByteArray to LabVIEW Byte Array conversion
      General and Desktop • qbytearray conversion bytearray labview const char • • UvQtcYZJuD7J5VW7  

      10
      0
      Votes
      10
      Posts
      116
      Views

      @UvQtcYZJuD7J5VW7 said in QByteArray to LabVIEW Byte Array conversion: I need to include Labview extcode.h Yes, that's right. and when I include it, I get errors about my compiler (platdefines.h doens't recognize my compiler when I'm in Qt Creator). Then you just need to address the error. If you use MSVC, it will work fine out-of-the-box. If you want to use MinGW, you can modify platdefines.h and add these 2 lines to define your compiler: ... #elif defined(__GNUC__) // <-- Add this #define Compiler kGCC // <-- Add this #else #error "We don't know the Compiler" #endif
    • UNSOLVED Converting QByteArray to QString
      General and Desktop • qprocess qstring qbytearray • • Sina Ranjkesh zade  

      13
      0
      Votes
      13
      Posts
      770
      Views

      @Sina-Ranjkesh-zade said in Converting QByteArray to QString: For "standard input" if you mean input arguments of the process, I got this error: No, I meant standard input. That is , the python program reads from a terminal and accepts input just as if you typed it (except it is the Qt program sending that input). The Qt program can send a command to the python program, send the data it needs, and read the result (if there is one) back on the python program's standard output. Or you can used shared memory, or a socket, or files, or do whatever the python program is doing in the Qt program...
    • SOLVED Is there a way to make output from QCryptographicHash readable QByteArray?
      General and Desktop • qbytearray • • artwaw  

      15
      0
      Votes
      15
      Posts
      141
      Views

      @JonB I can live with one pair of new/delete :) Thank you all who contributed and especially to @Christian-Ehrlicher for pointing me out the obvious.
    • SOLVED Get sound wave from QAudioInput
      General and Desktop • qbytearray qaudioinput sound • • Robotechnic  

      6
      0
      Votes
      6
      Posts
      141
      Views

      I fixed my problem: with a qDebug of lenght I have: data.length() lenght 136 2730 740 1364 1326 1366 414 1364 208 1366 458 1364 As you can see they are not the same so, with this code, my problem is fixed: void Window::processAudioFrame(QByteArray data){ const short* result = (short *)data.constData(); for (int i=0; i < data.length()/2; i ++ ){ ui->soundView->pushSoundLevel(result[i]); } }
    • SOLVED QByteArray strange behavior
      General and Desktop • qthread qbytearray • • Abhi_Varma  

      7
      0
      Votes
      7
      Posts
      128
      Views

      @jsulm I just now noticed this when I was debugging the code and was about to update here but I see u have already answered it. Thanks
    • SOLVED QByteArray::fromHex(QString.toUtf8()) presenting undesired behavior
      General and Desktop • qbytearray toutf8 fromhex • • oldevel  

      15
      0
      Votes
      15
      Posts
      225
      Views

      I gained insight from all your posts. It turns out that simply correcting the line length sorted the problem, thank you.
    • SOLVED Do I receive complete QByteArray when binaryMessageReceived is emitted?
      General and Desktop • qbytearray tcp networking qwebsocket • • noone  

      4
      0
      Votes
      4
      Posts
      216
      Views

      @JonB Thanks. I didn't know about those links. they look promising. This whole networking stuff is really new to me @Christian-Ehrlicher Thanks. So for large data, I guess QWebSocket::binaryFrameReceived() is the correct way
    • UNSOLVED Incomplete data in QDataStream when reading from QTcpSocket
      General and Desktop • qtcpsocket qtcpserver qbytearray qdatastream • • RBLL  

      16
      0
      Votes
      16
      Posts
      722
      Views

      Maybe that QByteArray is the culprit, you could try rewrite into more vanilla standard: ... { QByteArray block; QBuffer buffer(&block); buffer.open(QIODevice::WriteOnly); QDataStream out(&buffer); ... at least you would expose more stuff to the debugger :-)
    • SOLVED QDataStream an openCV::mat serialisation...
      General and Desktop • opencv qbytearray qdatastream • • Dariusz  

      3
      0
      Votes
      3
      Posts
      416
      Views

      @jsulm said in QDataStream an openCV::mat serialisation...: @Dariusz What is stream here? Is it QDataStream? "Any idea what did I mess up with this ?" - well, what is not working? Yep :- ) I think I might "got it". Naturally 5 min after asking question... elemSize1() return incorrect number of channels. Looks like I need elemSize() instead. still testing. Yep it was wrong element number. Hope it helps other "serializers" out here : -)
    • SOLVED QFile - read bytes, x at a time, x +offset?
      General and Desktop • qfile qbytearray qiodevice • • Dariusz  

      4
      0
      Votes
      4
      Posts
      798
      Views

      @Dariusz Simply seek to the position where you want to read and then read the amount of bytes you need. https://doc.qt.io/qt-5/qfiledevice.html#seek https://doc.qt.io/qt-5/qiodevice.html#read-1 You can seek to the beginning of the file if you decide to read whole file.
    • UNSOLVED Qaudiooutput Double values
      General and Desktop • qbytearray qvector qaudiooutput qbuffer • • Sareban  

      1
      0
      Votes
      1
      Posts
      195
      Views

      No one has replied

    • SOLVED How to get uint8_t from a QByteArray
      General and Desktop • qserialport qbytearray • • Dooham  

      3
      0
      Votes
      3
      Posts
      2928
      Views

      @Christian-Ehrlicher Thanks, that was exactly my problem.
    • UNSOLVED QtCreator Debugger evaluates wrong values
      Tools • debug qbytearray reinterpretcas • • JealousFish  

      8
      0
      Votes
      8
      Posts
      923
      Views

      @JealousFish Yes, In Qt Creator is called “Build Directory”, where file .o are created and where you find your application. In the past I had the same issue, when I deleted the build folder the problem disappeared. Sometimes, when compiler failed and the code seems ok, I delete the builder folder and the problem disappears. I think, but it is only my idea, when this happens some files .o are locked, perhaps because I stopped the previous compile.
    • UNSOLVED ArrayBuffer <-> QByteArray
      QML and Qt Quick • qbytearray conversion arraybuffer • • pderocco  

      1
      0
      Votes
      1
      Posts
      402
      Views

      No one has replied

    • SOLVED saveGeometry & restoreGeometry - what am I doing wrong ? - not restoring properly
      General and Desktop • qbytearray savegeometry restoregeometry savestate restorestate • • Dariusz  

      2
      0
      Votes
      2
      Posts
      954
      Views

      Ok got it solved. Since my widgets were a little "complex" as I had QDockWidget, that had QMainWindow, so that each dock widget could house sub dock widgets. The native QT storeGeometry did not work for DockWidgets and I needed storeState/restoreState, so I subclassed my widgets to work on states of my mainWindows instead of geometries. In any case it all works now. Hope this helps if any1 else tries it.
    • UNSOLVED How should i store the results ??
      General and Desktop • qtcreator qt5 json qbytearray json parser • • Qjay  

      6
      0
      Votes
      6
      Posts
      906
      Views

      @Paul-Colby Thanks i myself did something like this :) QVariantMap json_map; const QJsonDocument doc = QJsonDocument::fromJson(output); qDebug().noquote() << doc; qDebug().noquote() << doc.array(); foreach (auto value, doc.array()) { qDebug().noquote() << value; qDebug().noquote() << value.toObject(); qDebug().noquote() << value.toObject().value("name"); json_map["name"] = value.toObject().value("name").toString(); json_map["installed"] = value.toObject().value("installed").toBool(); json_map["id"] = value.toObject().value("id").toString(); json_map["filename"] = value.toObject().value("filename").toString(); }
    • SOLVED Returning QByteArray as Qvariant
      General and Desktop • qpixmap qvariant qbytearray return • • Euclide  

      8
      0
      Votes
      8
      Posts
      2694
      Views

      I found where the problem was! As Christian Ehrlicher said according to the Documentation QByteArray::fromRawData() only store the pointer to the data. That explain why it doensn't work outside the function since the data goes out of scope. Instead of using this method I used one the constructors that make deep copy of the data. And it just works fine! QByteArray data (value.dataPointer (), value.dataSize ()); return data; Thanks all!
    • SOLVED Large incoming data to QByteArray and what to do with it?
      General and Desktop • qbytearray qiodevice qtemporaryfile • • scottnat  

      4
      0
      Votes
      4
      Posts
      1018
      Views

      @sierdzio and @jsulm Thank you both for the suggestions. I will work on number 4 with moving of tempfiles or using a QSaveFile.
    • SOLVED Clicking sounds when playing Raw Audio.
      General and Desktop • qbytearray qiodevice qaudioformat raw audio notifyinterval • • scottnat  

      11
      0
      Votes
      11
      Posts
      2654
      Views

      Hi all, thanks for the assistance. The issue has been fixed. Initially i was attempting to read and write data sequentially to achieve Real Time audio playback. However, this probably caused the issue of buffer underrun. I decided to save all my incoming data into a qbytearray and then buffer qiodevice to write.
    • UNSOLVED How can I use the value(QByteArray) of one class in another?
      General and Desktop • qbytearray udp shared value shared • • ChristianMontero  

      9
      0
      Votes
      9
      Posts
      1919
      Views

      @Diracsbracket I think it should, let me try it, thanks you so much for your time!
    • UNSOLVED Passing QByteArray to a callable QJSValue
      QML and Qt Quick • qbytearray qjsvalue • • jernkuan  

      3
      0
      Votes
      3
      Posts
      645
      Views

      In the event that anyone else comes across this looking for a solution (like I was), Qt 5 and above can convert QByteArray to a Javascript ArrayBuffer. To do this, use toScriptValue: QJSEngine jsEngine = qjsEngine(this); QJSValueList args; args << title; args << jsEngine->toScriptValue(byteArray); callback.call(args);
    • UNSOLVED Save QImage to Base64 String
      General and Desktop • qimage qbytearray qbuffer base64 • • qDebug  

      9
      0
      Votes
      9
      Posts
      12527
      Views

      I did try to open the buffer (and close it). QByteArray ba; QBuffer bu(&ba); //bu.open(QBuffer::ReadWrite); bu.open(QIODevice::WriteOnly); image.save(&bu, "PNG"); //bu.close(); //QString imgBase64 = ba.toBase64(); QString imgBase64 = QString::fromLatin1(ba.toBase64().data()); qDebug() << "image base64: " << imgBase64; qDebug can't show the base64 string for some reason because std::cout << imgBase64.toStdString(); prints the correct base64 string. I did try serval version of code before i posted here. If i read the png from file and get a base64 from it, the same happens without the buffer. qDebug won't print out the base64 string. QByteArray ba; ba = file2.readAll().toBase64(); qDebug() << "base64 from png: " << ba.data(); // nothing std::cout << ba.data(); // works I wonder why.
    • UNSOLVED QMediaPlayer not playing from IODevice
      General and Desktop • qmediaplayer qbytearray qiodevice streaming qbuffer • • onek24  

      16
      1
      Votes
      16
      Posts
      8569
      Views

      @hariny , @onek24 Since this thread was not resolved; the buffer is not open !!! your are missing two lines of code: buffer->open(QIODevice::ReadOnly); buffer->seek(0);
    • UNSOLVED Convert QByteArray to QVector<qreal>
      General and Desktop • qbytearray qvector convert qreal • • Moldy  

      2
      0
      Votes
      2
      Posts
      4080
      Views

      that is wrong way of doing it try this: QByteArray bytesArray QDataStream out(&bytesArray ,QIODevice::WriteOnly); out << someVector; //saves it //////////////////////////////////////////////////////////////////// QDataStream in(bytesArray); QVector<qreal> otherVector; in >> otherVector; //load Please note that qreal is only 99.9% safe when saving to stream and sending it around to programs built with other versions of Qt. use QVector<double> instead
    • UNSOLVED QByteArray to QString containing hex data
      General and Desktop • qbytearray • • econsysqtdev  

      2
      0
      Votes
      2
      Posts
      3716
      Views

      @econsysqtdev QString hex(ba.toHex()); should work? PS: Note, however, that: ba[0] = 01; ba[1] = 80; ba[2] = 7F; ba[3] = 52; should rather be: ba[0] = 0x01; ba[1] = 0x80; ba[2] = 0x7F; ba[3] = 0x52;
    • SOLVED dataarray in QT sent to QSerialPort
      General and Desktop • qbytearray serialport writedata • • ktele  

      7
      0
      Votes
      7
      Posts
      2429
      Views

      Thanks! It worked!
    • UNSOLVED QSerialPort reading using QByteArray
      General and Desktop • qserialport qbytearray read • • michelson  

      3
      0
      Votes
      3
      Posts
      1931
      Views

      So does the QT appends '\0' terminator after every append? ( For QByteArray - No.
    • UNSOLVED How to display a variable of type QByteArray in Debug Window?
      General and Desktop • qbytearray hex debug window • • kahlenberg  

      3
      0
      Votes
      3
      Posts
      1561
      Views

      @kahlenberg Would this be of any use: http://doc.qt.io/qt-5/qbytearray.html#toHex
    • Slot and Qbytearray
      General and Desktop • qbytearray slot • • Gillou_beginqt  

      4
      0
      Votes
      4
      Posts
      1335
      Views

      Not every member function needs to be a slot. If it produces some value it doesn't sound very slottish. Consider you have a slot like QByteArray MyClass::saveData() and you connect it to some button: connect(button, &QPushButton::clicked, myObject, &MyClass::saveData). You can connect it that way but where would the byte array data go? Button is certainly not gonna do anything with it. Instead something like this seems more reasonable: class MyClass { ... public slots: //could be private or whatever void processPictureData() { savePictureData(loadPictureData()); } void savePictureData(const QByteArray& data) { /* write the data to some storage thing place */ } public: //could be private or whatever, but it's not a slot QByteArray loadPictureData() { // it could even be made static member to allow greater reusability /* do what you did and return the data */ } } Now you have a nice modular design, each piece of functionality reusable in isolation and hermetic. You can connect either of the slots to some signal. Btw. as the help in the footer suggests please use ``` around your code, not @.
    • Convert Hex To Binary using QByteArray class
      General and Desktop • qbytearray qt 5 binary format hex format • • Arshia  

      2
      0
      Votes
      2
      Posts
      1908
      Views

      Hi and welcome to devnet Check out fromHex
    • [Solved] sending QByteArray from QNetworkAccessManager
      General and Desktop • qimage qnetworkaccessm qbytearray qnetworkreply • • seang96  

      2
      0
      Votes
      2
      Posts
      1669
      Views

      I figured out what is going on, sort of. download_content in QByteArray seems to contains ^M (MSDOS newline) in some parts of the file when written to dump. When written to the desired file, it does not have those. Later on, in compareDownload the QBytearray does ontain the "^M" characters and the written file does not, therefore their bytes are different by x*^M. I currently do not understand why ^M is there and then not when written and I do not know how to remove from the QByteArray in the compareDownload function. Also during my tests to figure this out, QByteArray new_contents saves to file with ^M once I added that in there to compare with QByteArray file_byte_array. Edit: Actually the regular file that becomes file_byte_array does have the ^M, but the QByteArray that reads the file lacks it.
    • How to do Xor operation with QByteArray and copy it to another QBytearray[solved]
      General and Desktop • c++ error qbytearray xor operation • • vishnu  

      12
      0
      Votes
      12
      Posts
      5817
      Views

      @SGaist Windows 7 64bit/ Qt.5.4.1 /MinGw 32bit
    • QImage - Determine the proper scale to fit a specific Byte Array Size
      General and Desktop • qimage qbytearray save • • didu  

      3
      0
      Votes
      3
      Posts
      1006
      Views

      @cybercatalyst said: This dependes on the format, which most likely adds some kind of compression. The compression result is depend on the ordering of the pixels, which may be entirely different when pixels are differently aligned after scaling. This has a direct impact on the size in bytes. So, the conclusion is that there is some dependency (image contents, format, size) -> (size in bytes), but unless you aren't using an uncompressed format I wouldn't expect to be able to calculate the inversion of that function. This would be really complicated if even possible. Thanks for the answser. I think I will have to look for using BMP format. (https://support.microsoft.com/en-us/kb/132271) It is not the best optimization but it is the most quick calcul...
    • How to save binary file from QByteArray rather than QTextStream
      General and Desktop • c++ qbytearray qplaintextedit • • harveyab  

      3
      0
      Votes
      3
      Posts
      13655
      Views

      @Rondog Thank you. After a good nap I figured out what I needed. Your post confirmed it. (I didn't need the toLatin1(); either.)