Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.6k Topics 457.5k Posts
  • Dialog box Ui loading Slow in Qt C++

    Unsolved
    2
    0 Votes
    2 Posts
    218 Views
    C
    @prasad15 What and how much data is being loaded onto the text label? What other elements are in your UI? Does this happen if you load an empty dialog?
  • QtKNX - converting messages to human readable numbers

    Unsolved
    6
    0 Votes
    6 Posts
    488 Views
    M
    @J-Hilk Thanks for the response but I am not looking at manually assembling the bytes to get a value and then multiplying it with some coefficient. I was hoping that the QtKNX classes could do that for me. There is a fixed datapoint type class (QKnxFixedSizeDatapointType) and a lot for other int/float classes that inherit from it. I was hoping that by choosing the correct type, I could get the conversion and multiplication done for me. List of classes listed here: https://doc.qt.io/qt-5/qtknx-module.html Looking at the Qt source code, it looks like the value() function does not even do the multiplication with the coefficient in some cases. For QKnx2ByteFloat::value() there is no clear coefficient multiplication but there is a hardcoded multiplication by 0.01 see: https://github.com/qt/qtknx/blob/dev/src/knx/dpt/qknx2bytefloat.cpp float QKnx2ByteFloat::value() const { quint16 temp = QKnxUtils::QUint16::fromBytes(bytes()); quint16 encodedM = (temp & 0x87ff); // Turning on bits reserved for E. // Only needed for reinterpretation of negative values if (encodedM > 2047) encodedM += 0x7800; qint16 M = qint16(encodedM); quint8 E = (temp & 0x7800) >> 11; return float(0.01 * (M) * qPow(2, qreal(E))); } For QKnx2ByteSignedValue:value() there is a coefficient multiplication: double QKnx2ByteSignedValue::value() const { return qint16(QKnxUtils::QUint16::fromBytes(bytes())) * coefficient(); } For QKnx4ByteSignedValue::value() there is no multiplication: qint32 QKnx4ByteSignedValue::value() const { return qint32(QKnxUtils::QUint32::fromBytes(bytes())); } So how does one know when to manually multiply with a coefficient? Are we assuming that no QKnx2ByteFloat, QKnx4ByteSignedValue values will ever need multiplying with a coefficient, or will I have to manually subclass those? Would it not be better to always do the multiplication and just have a default coefficient of 1?
  • File-save doesn't prepend extension?

    Solved
    11
    0 Votes
    11 Posts
    646 Views
    JonBJ
    @clarify said in File-save doesn't prepend extension?: E.g. if my code tells the File Save dialog to save as a ".txt" file, then the user sees the .txt to the right of the cursor where he has to type the file name and he cannot delete the .txt. I really don't see how your accepted solution satisfies your stated requirement. Which is why I said Qt does not offer this. QDialog::setNameFiler() does nothing other than control what existing files QFileDialog displays. It does not even have any effect on the string(s) returned, which are just the current path in the viewport. Which may or may not have a .txt extension. You have to deal with that yourself in code. Also, the solution you have now is a file dialog for opening a file with the intention of reading. You should add dialog.setAcceptMode(QFileDialog::AcceptSave) for your intended "File Save operation". This will (a) change the title of the dialog (from "Open" to "Save As") and (b) change behaviour if an existing file name is selected or typed in (so that it asks about overwriting, as a user would expect). It's still not great as if there is a file named abc.txt and rather than selecting it the user types abc the file dialog does not treat this as abc.txt for checking, even though your code is likely to be appending the .txt according to your rule. But it's still better than leaving it on the default QFileDialog::AcceptOpen. So far as I can see, your requirement is reasonable, and may be implemented in other applications, but is not well supported in Qt.
  • :-1: error: error: unrecognized command-line option '-mylibrary'

    Unsolved
    3
    0 Votes
    3 Posts
    350 Views
    C
    Further to @SGaist's observation, I would guess that the calculator PRO file has an incorrect LIBS variable, e.g.. LIBS += ... -mylibrary rather than LIBS += ... -lmylibrary
  • Problem with scrolling in QScrollArea

    Solved
    7
    0 Votes
    7 Posts
    2k Views
    supergS
    @JonB Thank you! I tried QTimer::singleShot(0, ...) and it kind of worked, but still I found that my code had several problems. I have decided to do some refactoring so that I'll be easier to make this and other functionalities work better and easier. I was trying to avoid that but seems like it's the only way. Thanks again for your help, I'll mark it as a solution.
  • Location of SYSTEMSCOPE preferences (MacOS)

    Unsolved
    2
    0 Votes
    2 Posts
    158 Views
    SGaistS
    Hi, Which version of Qt is it ? On which version of macOS ?
  • Save QImage to Base64 String

    Unsolved qimage qbytearray qbuffer base64
    11
    0 Votes
    11 Posts
    17k Views
    M
    This works QBuffer buffer; buffer.open(QIODevice::WriteOnly); QImage qp(fileName()); qp.save(&buffer, "PNG"); QString base64 = buffer.data().toBase64(); https://stackoverflow.com/questions/69165252/how-to-convert-png-image-into-base-64-format-in-qt
  • 0 Votes
    1 Posts
    599 Views
    No one has replied
  • Qt Native Stye for macOS

    Solved
    3
    0 Votes
    3 Posts
    576 Views
    J
    @SGaist Thanks for the answer. In Qt 6.5, it finally support native macOS message box!
  • White screen on launching application on SurfacePro

    Unsolved
    5
    0 Votes
    5 Posts
    522 Views
    M
    @Abderrahmene_Rayene yes i have looked and found this thread https://forum.qt.io/topic/52625/qopenglshaderprogram-could-not-create-shader-program/8?_=1681473494310 As mentioned in this thread i am planning to check use DirectX via ANGLE but i am not sure if this will work QCoreApplication::setAttribute( Qt::AA_UseOpenGLES ); do you have any better suggestion than this please let me know
  • QStateMachine: How To Implement Logical OR Between States

    Unsolved
    1
    0 Votes
    1 Posts
    315 Views
    No one has replied
  • 0 Votes
    3 Posts
    713 Views
    A
    @SGaist Hey thank you, I removed the QObject heredity for every class since I don't need ^^ I made every copy constructor and operator= overload not usable (= delete) I made for each a static clone() method which makes a deep copy CueTrack * CueTrack::clone(CueTrack *other) { if(!other) return nullptr; CueTrack * trackToReturn = new CueTrack(); if(other->_animationsList) { delete trackToReturn->_animationsList; trackToReturn->_animationsList = AnimationsSubTrack::clone(other->_animationsList); } QVectorIterator<FxSubTrack*> it(other->_fxList); while (it.hasNext()) { auto p = it.next(); FxSubTrack * fx = FxSubTrack::clone(p); trackToReturn->appendFx(fx); } if(other->_zoneChase) trackToReturn->_zoneChase = ZoneChaseSubTrack::clone(other->_zoneChase); return trackToReturn; }
  • QComboBox - few questions

    Unsolved
    3
    0 Votes
    3 Posts
    249 Views
    Axel SpoerlA
    ...and for the records: It's all nicely written down here.
  • Memory leak in QAbstractSocketPrivate::readFromSocket() ?

    Solved
    12
    0 Votes
    12 Posts
    1k Views
    Axel SpoerlA
    @Alexey-Volkov thanks for letting us know what it was. Glad that it works. Please don’t forget to mark the issue solved.
  • QScrollBar slider shadow

    Unsolved qscrollbar shadow qt5.9.0
    1
    0 Votes
    1 Posts
    292 Views
    No one has replied
  • Updating Qt Line Series in Real-Time is not working

    Solved
    9
    0 Votes
    9 Posts
    1k Views
    X
    The real-Time Plot not working is already resolved above, and the blank chart area can be resolved by adding the following line. chartView->setMinimumSize( ui->frame->size() );
  • Simple Line Series Plot not Filling the Centeral Widget?

    Solved
    3
    0 Votes
    3 Posts
    340 Views
    X
    @JoeCFD said in Simple Line Series Plot not Filling the Centeral Widget?: @xpress_embedo said in Simple Line Series Plot not Filling the Centeral Widget?: chartView can you try to set size policy of frame to ? setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred ); you may set the same thing to chartView Thanks @JoeCFD for your suggestion. Unfortunately it didn't worked, I added the following lines of code. ui->frame->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred ); chartView->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred ); Later, I did the following changes and now the plot is okay. chartView->setMinimumSize( ui->frame->size() ); For me this is working, thanks for your support, and let me know if you or someone else has some suggestions for me.
  • How to save the widgets load using UiLoader?

    Unsolved
    2
    0 Votes
    2 Posts
    204 Views
    JonBJ
    @Kattia C++ being a compiled language you cannot do this, you cannot create variables at runtime, depending on what is in a file. (Python could, but not C++.) To get variables at runtime that is why you run uic on the .ui file at build time. Which produces a ui_...h file defining the class for ui with individually named variables for each widget. No more findChild<>() calls. So why are you loading the .ui file via UiLoader::load() dynamically at runtime instead of letting it get processed via uic at compile-time?
  • QMediaRecorder - How to access encoded data

    Unsolved
    1
    0 Votes
    1 Posts
    161 Views
    No one has replied
  • QWidget don't change color theme on macOS under specific circumstance

    Unsolved
    3
    0 Votes
    3 Posts
    221 Views
    S
    @SGaist There're another 2 necessary factors beside stylesheet: QScrollArea & QGridLayout. And another observation: go through it: print widget and window palette's rgb, delay printing to 3s later, and switch appearance; you will find that widget palette's RGB hasn't changed, but window palette's has.