Skip to content
  • Save very important data to a file

    Unsolved Brainstorm
    8
    0 Votes
    8 Posts
    3k Views
    mrjjM

    @AliReza-Beytari
    well for the file, the qt5-sqlcipher should do.

    For being hacker proof, its very important you dont store anything
    clearly in the exe file.

    That goes for the variables too.

    When u read into memory, make sure its not easy to locate
    and read. ( in mem)
    so do not store passwords or user names as clean text inside program.
    all must be encrypted.
    That will only keep noob hackers out.
    Anyone pro, will most likely be able to get access if
    unlimited access to app and data.

  • 0 Votes
    2 Posts
    2k Views
    Paul ColbyP

    The server is not returning anything useful in the HTTP headers (I wouldn't expect it to):

    ~/tmp$ wget -S 'http://u801.wapkafile.com//g03/video/1253022/7940/c8f9a32ef15648bfa6f693102de27835/DARNA-ZAROORI-HAI-3(Movies7.In).avi?md5=TU7ibYa85byjzJyJcH_LXQ&expires=1458916610' --2016-07-27 18:21:15-- http://u801.wapkafile.com//g03/video/1253022/7940/c8f9a32ef15648bfa6f693102de27835/DARNA-ZAROORI-HAI-3(Movies7.In).avi?md5=TU7ibYa85byjzJyJcH_LXQ&expires=1458916610 Resolving u801.wapkafile.com (u801.wapkafile.com)... 8.37.229.38 Connecting to u801.wapkafile.com (u801.wapkafile.com)|8.37.229.38|:80... connected. HTTP request sent, awaiting response... HTTP/1.1 200 OK Server: nginx Date: Wed, 27 Jul 2016 08:21:15 GMT Content-Type: video/x-msvideo Content-Length: 65707724 Connection: keep-alive Last-Modified: Wed, 31 Dec 2014 06:15:08 GMT Content-Disposition: attachment; filename="DARNA-ZAROORI-HAI-3(Movies7.In).avi" Accept-Ranges: bytes Expires: Wed, 03 Aug 2016 06:34:10 GMT Cache-Control: max-age=604800 Cache-Control: s-maxage=604800,max-age=604800 Age: 6425 X-Cache: HIT TCP_MEM_HIT dirn:0:1402323922 X-Swift-SaveTime: Wed, 27 Jul 2016 06:34:10 GMT X-Swift-CacheTime: 604800 Via: 440d210b[0,206-0,H] Length: 65707724 (63M) [video/x-msvideo] Saving to: 'DARNA-ZAROORI-HAI-3(Movies7.In).avi?md5=TU7ibYa85byjzJyJcH_LXQ&expires=1458916610.1’

    So Download Manager must be getting the info from the metadata at the start of the file.

    For example, I only downloaded the first 70KB of the file, and:

    ~/tmp$ file DARNA-ZAROORI-HAI-3\(Movies7.In\).avi\?md5=TU7ibYa85byjzJyJcH_LXQ\&expires=1458916610 DARNA-ZAROORI-HAI-3(Movies7.In).avi?md5=TU7ibYa85byjzJyJcH_LXQ&expires=1458916610: RIFF (little-endian) data, AVI, 640 x 360, ~30 fps, video: H.264 X.264 or H.264, audio: MPEG-1 Layer 3 (stereo, 22050 Hz)

    So the info is there at the start. I expect you'll want to use a library to parse it out. I'm not sure if Qt has such functionality built-in. Perhaps have a look through the Qt Multimedia docs.

    Cheers.

  • 0 Votes
    5 Posts
    2k Views
    QjayQ

    I just solved it myself (feels great ) . i used a property url to get url of file then assigned it to url of webview

  • 0 Votes
    4 Posts
    2k Views
    BharathiB

    QNetworkRequest req(url);
    reply=qnam.get(req);
    QObject::connect(reply,SIGNAL(finished()),this,SLOT(slotFinished()));

  • 0 Votes
    4 Posts
    3k Views
    T

    Since you seem to have some problems with QRegularExpression (Read the documentation! It's the best I have ever seen!), I will give you a small example. I happen to be using something like this in a program I am working on:

    QRegularExpression re("<img (?<junk>.*?) src=(?<path>\\S+?) (?<junk2>.*?)>"), QRegularExpression::CaseInsensitiveOption);

    The ?<name>-blocks are there to provide named captures in the matches. The first one is called junk - it is allowed to contain anything but the "src"-attribute (.*? matches any sign in a "lazy" manner). junk2 behaves equivalently; if you don't need to capture (i.e. store for later access) these groups, you could simplify the expression a bit.
    path will be storing the download-link for the image. \\S will match every non-whitespace character, +? means that there has to be at least one character like that. You will have to adapt to path including "-signs, depends on your specific case.

    Here a bit of code I copied and slightly modified from the documentation for QRegularExpression:

    QString s = "<img style=\"background-repeat: no-repeat; background-size: 100% 100%; vertical-align: -0.838ex;height: 2.843ex;\" src=http://en.wikitolearn.org/index.php?title=Special:MathShowImage&hash=2af9544640fe8b97375512027efaaccd&mode=mathml>"; QRegularExpressionMatch match = re.match(s); while (match.hasMatch()) { QString junk = match.captured("junk"); // junk == style=\"background-repeat: no-repeat; background-size: 100% 100%; vertical-align: -0.838ex;height: 2.843ex;\" QString junk2 = match.captured("junk2"); // junk2 == "" QString path = match.captured("path"); // path == http://en.wikitolearn.org/index.php?title=Special:MathShowImage&hash=2af9544640fe8b97375512027efaaccd&mode=mathml }

    Hand in your html-file instead of s, take care of some minute details (path enclosed in " or not? Maybe no space before junk2? etc.), and then you should be able to do whatever you want with your links.
    I hope that gets you started.

  • 0 Votes
    10 Posts
    5k Views
    F

    I had the same problem. Qt version is 5.12.3. Os is ubuntu 18.04 lts. Files can only be deleted periodically...

  • 0 Votes
    25 Posts
    9k Views
    jsulmJ

    The cause for that crash can be everything!
    How should anybody know what it is without your code?
    Did you try to debug your program to see where it crashes?

  • 0 Votes
    5 Posts
    4k Views
    ?

    @panosk
    Thanks it works :)

    Henrik

  • 0 Votes
    8 Posts
    4k Views
    M

    @kshegunov I didn't know that function. Thank you very much, I will try it.

  • Dynamic Path QFile

    Solved General and Desktop
    3
    0 Votes
    3 Posts
    2k Views
    cxamC

    @mrjj said:

    "/home/pics/" + name"

    Indeed, it worked. Thank you :)

  • 0 Votes
    9 Posts
    3k Views
    kshegunovK

    @dridk
    Hello,
    What I suggested is not compression per se, but a way to encode (meaning represent) base pair data more efficiently. As I noted, this is no way a complete solution, but I think it should give you a starting point. Since adenine is complementary to thymine the first could be encoded as a bit sequence 00 and the other as 11, while cytosine and guanine could be encoded as 01 and 10 respectively. This way you can get the complementary base by only inverting bits. Suppose you have encoded half the strain of DNA, then the complementary strain you get simply by inverting all the bits. Since the base data is only 2 bits fixed size you can use offsets to calculate where that data is exactly located in a long base pair sequence. Suppose you have a sequence of alleles and you know that some gene contains 3 alleles and starts with the 35th allele of the base-pair sequence, then you can access the gene sequence very easily. The gene should start at (35 - 1) * 3 = 102th base pair (or 102 * 2 = 204th bit) and the size is simply 9 base pairs or 18 bits. I just hope my biology is not failing me with the calculations. So if you had the whole sequence mapped in a binary file, to read up the gene you seek out the correct position directly by those offsets:

    QFile mySequenceFile("dnasequence.dna"); if (!file.open(QFile::ReadOnly)) ; //< You know the drill with handling errors file.seek(25); //< Go to the 25-th byte (200th bit) QByteArray geneSequenceData = file.read(3); //< Read 3 bytes (up to bit 224) // So in the byte array we've read we have the gene we're interested in, and it starts at the 4-th bit and ends at bit 22 // The total number of bits read is 24

    The whole point of having a structured binary file is to be able to seek around it without actually reading things. Obviously my example is pretty superficial and it's much better to have special class that represent a base pair sequence, class representing gene offsets and other data you might want to handle. Additionally, you probably'd need some meta-information written in that file (offsets of sequences, genes or other things) so you could locate what you need. This is not possible with text files, especially in a platform independent fashion. Moreover a sequence of 4 base pairs you encode in 4 bytes when you use text files, with the proposed encoding scheme you only need a single byte!

    Kind regards.

  • 0 Votes
    5 Posts
    5k Views
    raven-worxR

    @fbengo
    oops..sry my bad.
    but as i said... straight from my head :)

    just adapt the starting method:

    void someFunction() { QFile file(filePath); if (file.open(QFile::WriteOnly)) { QTextStream stream(&file); for (int r = 0; r < model->rowCount(); r++) this->printTree( 0, model->index(r,0), stream ); file.close(); } }
  • 0 Votes
    2 Posts
    782 Views
    jsulmJ

    Check the documentation for QMediaObject class: http://doc.qt.io/qt-5/qmediaobject.html
    Especially
    QVariant QMediaObject::metaData(const QString & key) const
    You probably will need to use QAudioDecoder class which is derived from QMediaObject.

  • Non-blocking local file IO in Qt5

    Unsolved General and Desktop
    8
    0 Votes
    8 Posts
    8k Views
    kshegunovK

    @detly said:

    Bah, in my rush before I forgot a vital detail: the structs will also be accompanied by blobs of binary data, in the realm of 32kB or more. Not something you'd normally pass on the stack, although I realise that signal data is marshalled and queued internally. Is this a "sensible" thing to use signals/slots for, or is 32kB+ the point at which I should be looking at more serious data sharing strategies?

    It is possible, although I advise you to implement implicit sharing. It's done quite easily through the QSharedDataPointer and QSharedData classes. Many of the Qt classes use those two to minimize actual data copying (including but not limited to all containers, images and the like). There are examples in the documentation how you can implement your own implicitly shared class, so I'll not make a point of it here. With sharing you could easily (and most importantly lightly) copy objects around that have payloads of megabytes without actually duplicating the data.

    Also, I'm assuming that if one thread emits a series of identical signals via the default connection type (which acts like a QueuedConnection across thread boundaries), they will be received in the same order. Is this correct?

    Yes, you are correct. The slot invocations are in actuality events in the event queue (for queued connections) of the thread, so they will be performed in the order of their arrival (the order in which signals had been emitted).

  • 0 Votes
    1 Posts
    1k Views
    No one has replied
  • 0 Votes
    3 Posts
    4k Views
    KiwiJeffK

    @reina
    Could you provide us with a usecase? In my experience, a QPixmap only interacts with file storage at initialization and is then a blob of data with an API for internal use.

  • 0 Votes
    4 Posts
    1k Views
    p3c0P

    @DidaHarp No. QML doesn't provide access to local files. In that case you will have to use C++ API's.

  • 0 Votes
    2 Posts
    2k Views
    p3c0P

    @Adityan-J Yes. Use QDataStream and QFile.
    Here's one example.

  • 0 Votes
    16 Posts
    11k Views
    K

    @jjan
    Just for an iteration the code reads line by line. As long as the search text is found, it will provide the remainder of the line. There is real dependency to the content as long as it is displayble (probably also some non-displayable characters). There are some special characters marking the end of lines (line feed (LF) and carriage return (CR) are those at least).

  • 0 Votes
    4 Posts
    2k Views
    SGaistS

    For Android you can use the Assets file system