Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.6k Topics 457.6k Posts
  • Happy Holiday

    Solved
    6
    1 Votes
    6 Posts
    544 Views
    Axel SpoerlA
    And to you, too!
  • Setup.exe Entry Point Not Found

    Unsolved
    2
    0 Votes
    2 Posts
    312 Views
    SGaistS
    Hi and welcome to devnet, I would start by searching which application gets automatically started. There's likely something messing up your within your PATH.
  • How to make a child widget be transparent for mouse events?

    Solved
    9
    0 Votes
    9 Posts
    877 Views
    F
    @SGaist I reread and reinterpreted the quoted statement in your post and finally got it why Qt::WA_TransparentForMouseEvents does not work for widget Y as I expected. The key part is "as if the widget and its children were not present in the widget hierarchy", so if Y is not present, then widget X will get a mouse event, which is not transparent, so mouse event won't go through X. Thanks.
  • are there only five kinds of layouts in Qt?

    Solved qt 6 qlayout layout
    4
    0 Votes
    4 Posts
    659 Views
    Pl45m4P
    @markleo said in are there only five kinds of layouts in Qt?: Or are there only five kinds of layouts in Qt? Yes and no. In most cases these are the base layouts used. However there are also custom layouts with "special" behavior, like FlowLayout from the Flow Layout Example. That being said, you can combine the basic layout or build your own layout, if you really need something different (what you cannot reproduce using the five above).
  • [SOLVED] Variable arguments

    13
    0 Votes
    13 Posts
    13k Views
    crimson1023C
    You can refer to this code. void my_printf(const char *format, ...) { va_list args; va_start(args, format); for (const char *p = format; *p != '\0'; p++) { if (*p == '%') { p++; // Move past '%' switch (*p) { case 'd': { // Handle integer int i = va_arg(args, int); printf("%d", i); break; } case 'c': { // Handle char char c = (char)va_arg(args, int); // char is promoted to int putchar(c); break; } case 's': { // Handle string char *s = va_arg(args, char *); printf("%s", s); break; } default: // Handle unknown format specifiers putchar('%'); putchar(*p); break; } } else { putchar(*p); // Print regular character } } va_end(args); }
  • How to unclick a QPushButton

    Solved
    7
    0 Votes
    7 Posts
    474 Views
    Pl45m4P
    The dialog literally says "Press ESC to cancel" :)
  • 0 Votes
    4 Posts
    373 Views
    JonBJ
    @markleo No, it will be far more expedient to use a Python debugger and its watch windows. Otherwise write whatever you want to display whichever variables however you want to see them from your program.
  • Modern titlebars in Qt widget based desktop applications

    Unsolved
    5
    0 Votes
    5 Posts
    555 Views
    S
    Sorry, I shared the incorrect blog post, I wanted to share this instead https://www.qt.io/blog/custom-window-decorations, though it doesn't solve much.
  • when using the qxorm to connect the sqlite ....

    Unsolved
    8
    0 Votes
    8 Posts
    506 Views
    SGaistS
    @nicker-player said in when using the qxorm to connect the sqlite ....: but the way u just mentioned could not get what I want. the qxorm need to use the qsqldatebase pointer from the intance.how can I get the real pointer from the method of QSqlDatabase::database() Beside the question of @jsulm, which method needing a pointer are you trying to call ?
  • Problem drawing flat QLineseries in QPolarchart

    Unsolved
    1
    0 Votes
    1 Posts
    68 Views
    No one has replied
  • Dialog name is shown twice

    Moved Unsolved
    5
    0 Votes
    5 Posts
    480 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
    166k 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
    597 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
    389 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
    4k 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
    255 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
    590 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
    1k 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
    789 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
    306 Views
    Christian EhrlicherC
    ... and please properly format your code with the code tags so others can read it.