Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.1k Topics 454.7k Posts
QtWS25 Last Chance
  • can't run QT6 in visual studio 2022

    Unsolved
    16
    0 Votes
    16 Posts
    9k Views
    G
    @HerrWinfried The problem is that VS2022 doesn't return by default the right value for __cplusplus No idea if that's a bug or a feature in VS2022. However, here the solution how to overcome this issue: https://docs.microsoft.com/en-us/cpp/build/reference/zc-cplusplus?view=msvc-170 cheers Greg
  • Parsing JSON file

    Solved
    23
    0 Votes
    23 Posts
    3k Views
    J
    @KroMignon said in Parsing JSON file: @jenya7 said in Parsing JSON file: It works. Thank you. But you did not reply to my question... What exactly did not work with your code? AFAIK, there is no difference between temperature.value("Maximum") and temperature["Maximum"]. Yes. It should be the same. Probably I didn't cast it to the right data type.
  • Try to deploy a Subdirs project in Linux.

    Unsolved
    8
    0 Votes
    8 Posts
    1k Views
    JonBJ
    @django-Reinhard Fortunately I do not distribute any Qt apps, so I have never used them :) But if I did I would be looking at using linuxdeployqt and windeployqt.
  • Action Focus behaviour

    Unsolved focus action focusscope shortcut
    1
    0 Votes
    1 Posts
    316 Views
    No one has replied
  • How can I place a qlabel over qwidget placed in a window container?

    Solved qlabel qwidget window
    6
    0 Votes
    6 Posts
    2k Views
    JKSHJ
    @new-qt_user-2022 All the best! Feel free to post new questions if you'd like further help.
  • QProcess: Start, interact and keep running when Application exits

    Unsolved
    12
    0 Votes
    12 Posts
    756 Views
    JonBJ
    @themts Assuming you do write a separate Qt "VPN spawner" application, you then have a choice if it helps: you can start that startDetached(), or if you prefer for communication with it you can start it with normal start() and have it do the startDetached() when it starts the VPN process.
  • how to change QComboBox items?

    Unsolved
    2
    0 Votes
    2 Posts
    303 Views
    Christian EhrlicherC
    Use QComboBox::setItemData() with Qt::EditRole (or Qt::DisplayRole - it's the same for the underlying QStandardItemModel)
  • QGraphicsItem receive mouse events based on bounding rect, not item shape

    Solved
    9
    0 Votes
    9 Posts
    1k Views
    E
    My bad, I was actually using QGraphicsView as a base. I've instead made a custom QGraphicsScene and I've overridden the mouse press event, like so: void CustomGraphicsScene::mousePressEvent(QGraphicsSceneMouseEvent *evt) { switch (evt->button()) { case Qt::LeftButton: { QList<QGraphicsItem *> items = this->items(evt->pos(), Qt::IntersectsItemBoundingRect); QListIterator<QGraphicsItem *> it(items); while (it.hasNext()) { QGraphicsItem *item = it.next(); if (item->boundingRegion(item->sceneTransform()) .contains(evt->pos().toPoint())) { item->setSelected(!item->isSelected()); break; // This can happen twice cuz of float rounding nonsense } } break; } case Qt::RightButton: { clearSelection(); break; } default: { break; } } QGraphicsScene::mousePressEvent(evt); } The reason I don't just use the graphics view mouse event is because, even though it was working before to an extent, it broke when I scrolled because the mouse event's position doesn't scroll with it. This doesn't work the same as that did, though, when it comes to selection of the whole item. Now I'm back where I started and am considering creating a rectangle around the point & getting the containing items of that & doing the boundingRect() logic myself. The code that somewhat worked before: void CustomGraphicsView::mousePressEvent(QMouseEvent *evt) { switch (evt->button()) { case Qt::LeftButton: { QList<QGraphicsItem *> items = this->scene()->items(evt->pos(), Qt::IntersectsItemBoundingRect); QListIterator<QGraphicsItem *> it(items); while (it.hasNext()) { QGraphicsItem *item = it.next(); if (item->boundingRegion(item->sceneTransform()).contains(evt->pos())) { item->setSelected(!item->isSelected()); break; // This can happen twice cuz of float rounding nonsense } } break; } case Qt::RightButton: { scene()->clearSelection(); break; } default: { break; } } QGraphicsView::mousePressEvent(evt); }
  • sql experts around?

    Solved
    11
    0 Votes
    11 Posts
    590 Views
    HoMaH
    @kshegunov Heureka! You put me onto the right track: I found the following SQL working on SQLITE, solving my problem: SELECT productId , dateOfP , (SELECT sum(value) FROM (SELECT value FROM purchases AS pu WHERE pu.productId = purchases.productId AND pu.dateOfP > DATE(purchases.dateOfP, '-1 years') AND pu.dateOfP <= purchases.dateOfP) ) AS Summe FROM purchases GROUP BY dateOfP So thank you and also to Christian, who pointed into the right direction!
  • Dealing with lots of objects is very slow

    Unsolved
    3
    0 Votes
    3 Posts
    305 Views
    mrjjM
    Hi That many labels are heavy to draw. A listView / Table with a delegate will be much faster. Look at https://forum.qt.io/topic/62363/custom-delegate/3 for starter code.
  • How to create a QImage or QPixmap from raw pixel data (TGA)

    Solved
    4
    0 Votes
    4 Posts
    1k Views
    Christian EhrlicherC
    @Meeuxi said in How to create a QImage or QPixmap from raw pixel data (TGA): bytesPerLine You must know this since you created the raw image data CleanupFunction and *cleanupinfo. Since char* data need to stay alive until the whole lifetime of the QImage object (as stated in the documentation) you have two options a) create a QImage::copy() of the qimage so the bytes are copied b) make sure to delete the bytes when the image gets destroyed - this is what the cleanup function is for. So pass a function which cleans up your image data.
  • Take from to QString

    Solved
    3
    0 Votes
    3 Posts
    268 Views
    S
    Hi @JonB, thanks for your reply. Ok, I'll try to look it up more before I ask here.
  • use of undeclared identifier 'qDebug '

    Solved
    4
    0 Votes
    4 Posts
    392 Views
    Christian EhrlicherC
    Why do you ask the same question every week (and deleting the old topic afterwards)? https://forum.qt.io/topic/133112/qdebug-compile-problem
  • Calling MainWindow code from QGraphicsItem objects

    Solved
    6
    0 Votes
    6 Posts
    426 Views
    A
    Now it finally starts making sense. I was able to link the signals and slots together thanks to your explanation. I think the signal procedures are like radio transmitters that emit a message at a certain frequency. And a slot is the transmitter that must be tuned to the same frequency with connect() to be useful. But just like in radio, repeater receiver/transmitter pairs (chaining) are needed over long distances (across class boundaries). Please excuse my ramblings and many thanks for your helpful, clear explanations.
  • disabling all keyboard input to a dialog

    Unsolved
    2
    0 Votes
    2 Posts
    340 Views
    JonBJ
    @Kent-Dorfman +1 for your command of the English language to (correctly) use "one fell swoop", and not the spelling so often found which refers to football or chickens... :) In a single word, is the way to achieve your desired behaviour by defining an eventFilter() on the dialog, where you can select which events to handle/pass on and which to ignore?
  • Do I need the private libraries in order to make a custom QGraphicsLayout?

    Unsolved
    2
    0 Votes
    2 Posts
    178 Views
    C
    @Kill-Animals said in Do I need the private libraries in order to make a custom QGraphicsLayout?: do I need to be using the private libraries here No. They are private to the Qt library itself for a reason. The subclasses that already exist layout items in non-overlapping areas (horizontally, vertically, or both). It sounds like you want something far more complex than that. If you want to handle this as a layout manager then you really have no choice but to subclass QGraphicsLayout. When you do that your subclass needs to implement its own logic for all of the pure virtual members and develop its own mechanisms for actually laying out the contained items. It should not need to reach into the private workings of the abstract QGraphicsLayout to achieve this.
  • Undefined Reference

    Unsolved
    8
    0 Votes
    8 Posts
    410 Views
    O
    My mistake. If you note the second constructor does what I want: get a two dimensional array of [row ][column] that will allow me to construct a contiguous array of qreals. White the final constructor I was trying to make it less verbose. Some other languages allow something like x[0][:] to return and array with the first row of x[][]. Also, I will note that I have watching on but I do not get a notification unless I click no the icon, before a number, representing the number of notifications, would appear on the icon.
  • Creation of custom menubar.

    Solved
    7
    0 Votes
    7 Posts
    914 Views
    A
    @JonB You are right. I will try.
  • QTableWidget has blank cells after I set their strings

    Solved
    11
    0 Votes
    11 Posts
    825 Views
    JonBJ
    @Publicnamer I look forward to your future illustration of such fundamental bugs in QString. The problem with programmers these days is that they do insist there are no bugs (without evidence), I don't agree with your sentiment here. Rather I find the problem with (some) programmers is that they are too quick to blame their tools --- toolkit, Qt, whatever --- when they should reflect on how widely used it is among other people and it is their own code they should examine instead. Speaking at least from experience on this forum I know just how many people come say "there is a bug in Qt" when their own code is faulty. Lots & lots of times....
  • Multiple definition of '__imp___C_specific_handler'

    Solved
    6
    0 Votes
    6 Posts
    724 Views
    JonBJ
    @pingal That is a funny one! Windows should be case-insensitive, filename-wise. However, it looks like MinGW linker is case-sensitive to some degree.