Skip to content
  • Convert from qMake to Cmake

    Unsolved Qt 6
    2
    0 Votes
    2 Posts
    593 Views
    SGaistS

    Hi and welcome to devnet,

    Just keep using cmake.

    Here for Qt 5

    Here for Qt 6

  • 0 Votes
    2 Posts
    363 Views
    jsulmJ

    @surajj4837 said in Deploy UI file on QNX:

    This step is not happening

    What does this mean please?
    Post error message or describe better what happens.
    Do you have CMake in your QNX SDK?

  • 0 Votes
    7 Posts
    912 Views
    L

    @jsulm said in Storing QTextCharFormat and QColor to text file?:

    QTextStream & operator<<(const QTextCharFormat&)

    Hi, I have searched around how to write overloaded function for the operator, but I have not seen any example on the syntax you're using.

    I have declared QTextStream & operator<<(const QTextCharFormat&) in the class' header file, and in the source file, it should be something like this?

    QTextStream &SettingsDialog::operator<<(const QTextCharFormat &b) { stream << "font: " << b.font().toString() << " font-family: " << b.fontFamily(); return stream; }

    But I don't know where do I pass in the stream in the implementation.

  • 0 Votes
    2 Posts
    2k Views
    JKSHJ

    @GhostWolf said in 2's complement convertion:

    uint32_t test2 = (unit.value(1)<<16) | unit.value(0);

    Just store the result as a signed integer (int32_t) instead of unsigned (uint32_t).

    You don't need to change the bit pattern (0b11111111_11111111_11111111_11111111).

    Interpreting this pattern as Unsigned gives you ‭4294967295 Interpreting this pattern as Signed gives you -1.
  • 0 Votes
    6 Posts
    6k Views
    McLionM

    @raven-worx
    Seems I was not looking at the right place or not well enough.

    QTime zero(0, 0, 0, 0); QDateTime EndTimeLocal = StartTimeLocal.addSecs(zero.secsTo(duration));

    Thanks anyway :-)

  • 0 Votes
    11 Posts
    6k Views
    VRoninV

    slightly more refined solution using the fact that QImage uses "a matrix" internally

    QDataStream outStream(&outputFile); outStream << image.height()<< image.width(); /* You need this to recover the image size, if not needed remove*/ QImage testImage= image.convertToFormat(QImage::Format_Mono,Qt::MonoOnly); /* 1 bit= 1 pixel*/ testImage.invertPixels(); /* black is 1 and white is 0 normally, you need the opposite so invert*/ const int bytesInWidth = testImage.width()/8 + (testImage.width()%8>0 ? 1:0); /*This is image.width()/8 rounded up */ for(int i=0;i<testImage.height();++i) outStream.writeRawData((const char*)(testImage.constScanLine(i)),bytesInWidth);
  • 0 Votes
    4 Posts
    3k Views
    raven-worxR

    @Shidharth
    Maybe you can extract a QWebElement and insert it into a separate QWebView and use print(). But i think it may not look the same as in the origin QWebView.

    Also maybe there is a possible JavaScript way?

  • 0 Votes
    5 Posts
    22k Views
    Ni.SumiN

    Hi @Wieland ,

    I did not test the code. But Yes, you are right. I tested @Punit 's code after my comment. It worked for me too(missed only that semicolon).

  • 0 Votes
    2 Posts
    5k Views
    VRoninV

    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

  • 0 Votes
    9 Posts
    37k Views
    R

    @Chris-Kawa thanks for all your help.

    Using a double instead of float I can get good display precision for up to 17 digits (which meets my minimum, but I'd prefer it if I could go even higher), so now this happens:

    12345678901234567 -> 12345678901234568

    As for 'f', the problem I'm having with using 'f' over 'g' is that they handle the given precision number differently, if i put say

    QString::number(12, 'f', 2);

    it will be printed as 12.00 (basically it adds zeroes after the dot to fill in every slot that doesn't have a number in it with zero, so if I put precision to 42, I will get 42 zeroes, or 12.000000000000000000000000000000000000000000; if I put 0 precision, then I get flat 12 as I would want. Regardless of what I set the precision to, the main number (before the dot) will always support 17 digits before getting scrambled, but if I don't add numbers after the dot, it adds zeroes for every possible point precision as given by the number (although if I'm reading correctly into these operations, that one will also get scrambled after the 17th digit just like the one before the dot))

    While for 'g', the precision number sets the total amount digits it can represent before getting scrambled, so unlike 'f', if I set the value to 2, it will get scrambled at 123 (on the 3), but just as 'f', if I set it to something high like 42, it will still get scrambled after the 17th digit.

    What I want is to represent numbers that can go from 1 to 999999999999999.99 (minimum, ideally I'd want even higher possible presicion) with the numbers after the dot being limited to two per number (hence the .99) 'f' seems to handle this fairly well if I give it 2 point precision, however the problem there is of course that any integer number will have .00 appended to it, and I do not want that. I want 12 to be read as 12 and not 12.00, while I want 12.2 to still be read as 12.2 or 12.20 (either way is fine since it's the same value, but I definitely would not want it shown as 12.199999999999999 which is what I get if it has higher precision).

    There is some rounding that needs to be done on the numbers during calculations but I think I will handle that separately (so the output to the display would always be a number with a maximum of 2 point numbers to work with)

    Well, if there's any way to use the 'f' with 2 point precision number and prevent the output from printing .00 after every single number that doesn't use points, then I guess my problem would be solved.

  • 0 Votes
    4 Posts
    3k Views
    SGaistS

    You can create the QLineEdits dynamically