Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
84.1k Topics 460.4k Posts
Qt 6.11 is out! See what's new in the release blog
  • Dialog name is shown twice

    Moved Unsolved
    5
    0 Votes
    5 Posts
    1k Views
    K
    @Pl45m4 What would happen if I try name of the window? I still tried and no success...! It just set name of window but it still appear twice
  • [SOLVED] libpng warning: iCCP: known incorrect sRGB profile drive me nuts

    21
    0 Votes
    21 Posts
    181k Views
    D
    First of all, my image is displayed correctly, despite the warning. I fixed the warning by opening in "Snip & Sketch" Windows application and then, saving it again.
  • I do not understand when to use QAbstractItemModel::createIndex()

    Unsolved
    4
    0 Votes
    4 Posts
    1k Views
    GrecKoG
    The mapToSource in the StackOverflow answer is incorrect. Not because it calls index but because it returns an index from the proxy model and not from the source model. It should be sourceModel->index(...) instead of index(...). createIndex is potentially cheaper to call, but for that you'd have to now what should the internal pointer be, so it is not always possible to do so. index would set the internal pointer correctly. Call createIndex when you can (or need), call index instead. In a tree model the internal pointer is needed to retrieve where you are in the tree hierarchy from an index, in a flat table or list model it is not needed but might be used for optimization.
  • 1 Votes
    6 Posts
    1k Views
    crimson1023C
    Yeah, you are right, but I don't know how to implement this so came here to discuss with you.
  • QSqlRecord - column indices inconsistency

    Unsolved
    24
    0 Votes
    24 Posts
    13k Views
    MasterQM
    not yet. As I wrote earlier I dropped the proxymodel and rearranged the database. While now struggling with the mentioned issue of not being able to write back data I will have to step back and to reactivate the proxymodel again. This will take time. Since I am sure the next proxymodel is just around the corner I may apply your suggestions then. Nevertheless, I learned a lot and for today I will shut down. Have a good time. Joachim
  • Qt 5.15.2 gstreamer avi playback error

    Solved
    3
    0 Votes
    3 Posts
    607 Views
    KutyusK
    @SGaist Thanks for the answer. I forgot to write that it is a raspberry pi. I did a bit of research and it was recommended to increase the kernel gpu_mem setting, so maybe the hardware acceleration will work, but the interesting thing happened, if I increased the default 64MB to 128, the error remained, but if I decreased it to 16MB , the error does not appear.
  • Eventloop/Event dispatching

    Solved
    5
    0 Votes
    5 Posts
    1k Views
    A
    @IgKh thanks! I think this is it. I will look further around these.
  • Changing "CodeEditor" example code.

    c++ qtwidgets qtextedit
    6
    0 Votes
    6 Posts
    3k Views
    I
    @Khamza It is quite hard to tell. The piece of code you pasted has several issues unfortunately, and it would very hard to say what the exact cause it without the whole thing to reproduce. I'll say that the most pressing problem in the code is that you are using values that are in document coordinates (which is what the rectangle that QAbstractTextDocumentLayout::blockBoundingRect returns is in) to calculate parameters for a QPainter which works in viewport coordinates. These are not the same, especially when there are scroll bars shown, and in my experience the main cause of issues around scrolling. That said, it wouldn't explain the text itself just disappearing when scrolling back up; I'd expect it to just be garbled. First try to comment out your paintEvent to see if text is drawn correctly at the expected positions when scrolling back and forth - perhaps something in the formats isn't right. Otherwise, please post a complete yet minimal project that reproduces the problems you see.
  • QTextCursor::mergeBlockFormat() doesn't set format.

    Solved c++ qt widget qtextedit qwidget
    4
    0 Votes
    4 Posts
    2k Views
    JonBJ
    @Khamza First to answer your question. Your new code delays the update till after the text edit has been shown. In that sense it is similar to the QTimer approach. For unknown reason you are claiming the code does not work correctly until after the text edit has been shown. There are cases in Qt which this is necessary. In particular sizes of widgets are not calculated till they are actually shown, so code which requires to know a size is often delayed in one of the above two fashions. HOWEVER I was never convinced by your assertion "The function itself is called but neither text is inserted nor block format changed:". While I could believe that possibly an operation on textCursor() might require the text edit to be shown I never thought that insertPlainText() for sure would depend on that. It should be callable any time, including e.g. during construction. I have now had time to create a minimal repro. Here are the 3 files: #include "passwordshowarea.h" #include <QApplication> int main(int argc, char *argv[]) { QApplication a(argc, argv); PasswordShowArea w; w.show(); return a.exec(); } #ifndef PASSWORDSHOWAREA_H #define PASSWORDSHOWAREA_H #include <QTextEdit> class PasswordShowArea : public QTextEdit { Q_OBJECT public: PasswordShowArea(QWidget *parent = nullptr); private: void init(); void updateBlockFormat(); }; #endif // PASSWORDSHOWAREA_H #include <QAbstractTextDocumentLayout> #include <QTimer> #include "passwordshowarea.h" PasswordShowArea::PasswordShowArea(QWidget *parent) : QTextEdit(parent) { init(); //doesn't work updateBlockFormat(); // works - gpt4 suggest // QTimer::singleShot(0, this, &PasswordShowArea::updateBlockFormat); } void PasswordShowArea::init() { // QObject::connect(document()->documentLayout(), &QAbstractTextDocumentLayout::update, // this, &PasswordShowArea::updatePasswordShowArea); setTextColor(palette().color(QPalette::Text)); } void PasswordShowArea::updateBlockFormat() { insertPlainText("Some text"); QTextBlockFormat fmt = textCursor().blockFormat(); fmt.setTextIndent(20); fmt.setLineHeight(fontMetrics().height() * 2, QTextBlockFormat::LineDistanceHeight); fmt.setBackground(Qt::red); textCursor().mergeBlockFormat(fmt); } I have made couple of tiny tweaks where I did not have all of your code. I added fmt.setBackground(Qt::red); so that we had something to see. And here is what I get: [image: f7a0cc88-52cf-437f-8f38-cd3c2983b5bf.png] You can see that not only do I get the inserted text but I do also get the QTextBlockFormat changes. Identical if I change it to only call updateBlockFormat() on the delayed timer. Ubuntu 24.04, Qt 6.4.2. Sooo.... I suggest you try just this code.
  • can't write to QIODevice timely.

    Unsolved
    3
    0 Votes
    3 Posts
    661 Views
    Christian EhrlicherC
    ... and please properly format your code with the code tags so others can read it.
  • Is the following assignment operation on a QByteArray reference safe?

    Solved
    3
    0 Votes
    3 Posts
    671 Views
    S
    @Christian-Ehrlicher I incorrectly assumed that QByteArray would always create a deep copy of the data which was not true for QByteArray::fromRawData (documented behaviour, that I didn't read). So just wanted to confirm if this would behave as intended.
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    6 Views
    No one has replied
  • QChronoTimer doesn't work as expected

    Unsolved
    4
    0 Votes
    4 Posts
    1k Views
    C
    @Christian-Ehrlicher said in QChronoTimer doesn't work as expected: /edit: Looks like it's a windows only issue which will be fixed in the near future. Good, so I am not going mad then :)
  • Add New Localisation Language to Qt6

    Unsolved
    2
    0 Votes
    2 Posts
    475 Views
    No one has replied
  • How to receive mouse events for QDoubleSpinBox

    Solved
    23
    0 Votes
    23 Posts
    8k Views
    S
    @JonB Oops! My Bad :) The solution worked. Thank you for your patience.
  • Label cut off

    Unsolved
    1
    0 Votes
    1 Posts
    392 Views
    No one has replied
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    5 Views
    No one has replied
  • Trouble creating QMYSQL plugin for macOs.

    Solved
    3
    0 Votes
    3 Posts
    856 Views
    H
    @hskoglund -DCMAKE_OSX_ARCHITECTURES="arm64" did not work; the additional command in your post fixed the issue. Thank you.
  • Touchscreen not working with any Qt based application. But it works fine with GTK ones.

    Unsolved
    4
    0 Votes
    4 Posts
    750 Views
    I
    @Asperamanca I have set that flag in QML. But even if that was the only problem in my case, I don't understand why Qt based apps don't even register taps as clicks by default like GTK does. Here's the code for my simple app. import QtQuick import QtQuick.Window import QtQuick.Controls import QtQuick.Dialogs Window { width: 640 height: 480 visible: true title: qsTr("Hello World") flags: Qt.WA_AcceptTouchEvents Rectangle { id: button signal clicked property alias text: buttonLabel.text height: 50 width: 150 radius: 3 color: "gray" TapHandler { id: tapHandler onTapped: console.log("clicked2") } MouseArea { anchors.fill: parent onClicked: console.log("clicked") } Text { id: buttonLabel text: "Click Me" color: palette.buttonText anchors.centerIn: parent } } }
  • QSslKey: Unsupported encryption cipher OID: "2.16.840.1.101.3.4.1.42"

    Unsolved
    3
    0 Votes
    3 Posts
    636 Views
    C
    You really should check that your various QFile open calls succeeded. QSslKey may be the one complaining, but your certificates may be null.