Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.6k Topics 457.8k Posts
  • This topic is deleted!

    Unsolved
    4
    0 Votes
    4 Posts
    17 Views
  • Request help

    Unsolved
    4
    0 Votes
    4 Posts
    253 Views
    JonBJ
    @Pl45m4 said in Request help: I do, :)
  • A question about connect funtion

    Unsolved
    5
    0 Votes
    5 Posts
    347 Views
    JonBJ
    @Saymyname So your case would become: connect(this, &MyClass::fooSig, this, &MyClass::fooSlot); Don't you think this is nicer? It is also checked at compile time, so you will get a compilation error if the signal or slot does not exist or does not take the right arguments.
  • Two colors of the QLineSeries

    Unsolved
    7
    0 Votes
    7 Posts
    1k Views
    V
    @jsulm can you help me to solve this: https://forum.qt.io/topic/150794/qml-graph-glitch
  • Hints about HTTP REST service vs database

    Unsolved
    9
    0 Votes
    9 Posts
    456 Views
    N
    For your setup involving a Qt application and a PHP web page, using a database seems like the smoother path. Your web page can retrieve data as needed, while you maintain data consistency by syncing the database with your QList in the Qt app. This way, both your Qt app and web page stay on the same page with the data.
  • Detect a database error before executing a query

    Unsolved
    8
    0 Votes
    8 Posts
    1k Views
    M
    @JonB I saw that thread, but here I'm not using an explicit query. I'm using the QSqlTableModel - not sure if I can change something here (i.e. call QSqlQuery::exec() with a pre-built string instead of using QSqlQuery::prepare()). How to investigate on MySQL side? I checked /var/log/mysql/error.log but there are no entries. How to exclude it does not depend on my Qt code?
  • QVideoFrame conversion to QImage seems to corrupt my image

    Unsolved qvideosink qimage video frame
    2
    0 Votes
    2 Posts
    643 Views
    jsulmJ
    @friendlyQtBeginner I guess you should connect to videoFrameChanged() signal as described in documentation to make sure there actually is a frame when you call videoFrame: "QVideoSink will provide individual video frames to the application developer through the videoFrameChanged() signal." You can also call https://doc.qt.io/qt-6/qvideoframe.html#isValid to check whether you got a valid frame.
  • Qt app does not call terminal if call program from executable (application/x-executable

    Unsolved
    3
    0 Votes
    3 Posts
    231 Views
    Pl45m4P
    @JacobNovitsky I'm just guessing that this is what you are looking for: QProcess and start the terminal with your OS specific command (you didn't mention your OS)
  • How to locate moc files relate to MainWindow and other UI

    Unsolved
    2
    0 Votes
    2 Posts
    159 Views
    Christian EhrlicherC
    They are somewhere inside the build folder - no need to know the location exactly since cmake is doing the correct things.
  • A continuous capture of a window sceen as QPixmap? for OpenCV

    Solved
    7
    0 Votes
    7 Posts
    517 Views
    J
    The trick is to get targetWindowId and feed that to QScreen grabWindow. This will give you QPixmap format which is easily converted into OpenCV cv::Mat. For that I picked a class which is called private in Qt source code because it is not part of their API. class QCapturableWindowPrivate : public QSharedData { public: using Id = size_t; QString description; Id id = 0; static const QCapturableWindowPrivate *handle(const QCapturableWindow &window) { return window.d.get(); } QCapturableWindow create() { return QCapturableWindow(this); } }; class Screenshot { public: Screenshot(const QString& windowName); void displayLiveView(); private: QPixmap grabWindow(); WId targetWindowId = 0; QWindowCapture windowCapture; }; Screenshot::Screenshot(const QString& windowName) { WindowListModel windowListModel; windowListModel.populate(); QCapturableWindow targetWindow; // Window we are looking for bool windowFound = false; for (int i = 0; i < windowListModel.rowCount(); i++) { QModelIndex index = windowListModel.index(i); if (index.isValid()) { QString currentWindowDesc = windowListModel.data(index, Qt::DisplayRole).toString(); if (currentWindowDesc.contains(windowName)) { targetWindow = windowListModel.window(index); windowFound = true; break; } } } if (!windowFound) { qDebug() << "Window not found!"; return; } windowCapture.setWindow(targetWindow); auto handle = QCapturableWindowPrivate::handle(targetWindow); targetWindowId = handle ? handle->id : 0; } QPixmap Screenshot::grabWindow() { if (targetWindowId == 0) return QPixmap(); QScreen *screen = QGuiApplication::primaryScreen(); if (!screen) return QPixmap(); return screen->grabWindow(targetWindowId); } void Screenshot::displayLiveView() { while (true) { QPixmap pixmap = grabWindow(); if (pixmap.isNull()) { qDebug() << "Failed to capture the window."; continue; } QImage image = pixmap.toImage(); cv::Mat mat(image.height(), image.width(), CV_8UC4, (void*)image.constBits(), image.bytesPerLine()); cv::imshow("Live View", mat); if (cv::waitKey(30) == 27) { break; } } } int main(int argc, char *argv[]) { QApplication app(argc, argv); // Print available windows WindowListModel model; for (int i = 0; i < model.rowCount(); i++) { QModelIndex index = model.index(i); if (index.isValid()) { QString windowDesc = model.data(index, Qt::DisplayRole).toString(); std::cout << i + 1 << ". " << windowDesc.toStdString() << std::endl; } } Screenshot screenshot("Settings"); //The name of the window from the printed list screenshot.displayLiveView(); return 0; }
  • Different coordinates after setGeometry applied to QGraphicsView

    Unsolved
    5
    0 Votes
    5 Posts
    458 Views
    D
    @KenAppleby-0 Thank you. Now I am trying to understand why every app adapt dpi differently, Gimp, Firefox and Qt.
  • Working with Graphics View Framework and QSvgItem

    Solved
    2
    0 Votes
    2 Posts
    191 Views
    C
    So I asked chat GPT and it gave some suggestion that seem to work: void centerSVGItem() { QRectF transformedBoundingRect = svgItem->sceneTransform().mapRect(svgItem->boundingRect()); QPointF svgCenter = transformedBoundingRect.center(); QPointF sceneCenter = scene->sceneRect().center(); QPointF offset = sceneCenter - svgCenter; svgItem->setPos(svgItem->pos() + offset); }; //... QObject::connect(action1, &QAction::triggered, [&]() { QRectF transformedBoundingRect = svgItem->sceneTransform().mapRect(svgItem->boundingRect()); svgItem->setTransformOriginPoint(transformedBoundingRect.center()); svgItem->setRotation(rotation += 45); centerSVGItem(); scene->update(); }); [image: 62459644-d48c-4a14-9c20-0e95e1b6d73d.gif] If you have any other suggestions or ideas please feel free to comment.
  • Qt6 platform rendering issues on Ubuntu 22.04

    Unsolved
    31
    0 Votes
    31 Posts
    8k Views
    R
    The default application palette seems to be broken in places with Qt 6.5 and higher. As a workaround, I serialized the working palette into a file using the testlabel app, compiling it with Qt 6.4.3. Then I added the resulting binary file to my application resources. When compiling it with a higher Qt version, I merely overwrite the default palette into the app instance. Seems to work OK; now at least I can do some more serious testing.
  • QDoc is not generating output for \property and \enum

    Unsolved
    1
    0 Votes
    1 Posts
    159 Views
    No one has replied
  • 0 Votes
    35 Posts
    4k Views
    JonBJ
    @saerpa I respect what you have chosen to do, maybe there is a difference in MinGW compiler or even in Qt. However, are you aware that Qt 5.9 is really old now? It may have issues which have been resolved. I leave you with the thought that it might be better to move to a newer version, assuming one of those does work correctly with MinGW 32-bit.
  • How to read data in questDB with QT application?

    Unsolved
    9
    0 Votes
    9 Posts
    1k Views
    JianJianJ
    @newKid can you show the code how to made it, i have the same condition, use quesdb in qt application,tks
  • get milliseconds from QTimeEdit

    Solved
    7
    0 Votes
    7 Posts
    1k Views
    E
    Hi Chris, maybe I'm completely wrong. I think my problem is a different one. I grab the time value in a keyPressEvent loop. SO you enter the last number and press then Enter or Return. But the QTimeEdit didn't recognize the last entered number yet. if(event->key() == Qt::Key_Return|| event->key() == Qt::Key_Enter||event->key() == Qt::Key_Tab) { ... } If I put in if(event->key() == Qt::Key_Return|| event->key() == Qt::Key_Enter||event->key() == Qt::Key_Tab) { QTimeEdit::keyPressEvent(event); ... } I get the correct results. Thanks for your support. Without, I couldn't figure out my mistake.
  • After upgrading to Win11, compiling project is failed.

    Solved
    3
    0 Votes
    3 Posts
    282 Views
    W
    @Christian-Ehrlicher Thank you for your reply. After trying, this issue is solved. Have a nice day.
  • Qt5Test.dll error After Deployment of OpenCV application

    Unsolved
    4
    0 Votes
    4 Posts
    432 Views
    Christian EhrlicherC
    If you would not use anything from QTest library then windows would not ask for it. Maybe look with Dependency Walker to see where it comes from.
  • 0 Votes
    9 Posts
    596 Views
    Christian EhrlicherC
    @Crag_Hack Yes