Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.7k Topics 457.9k Posts
  • Emitting signal from the same slot it is connected to.

    Unsolved
    4
    0 Votes
    4 Posts
    382 Views
    S
    Recursion can always lead to a place where the stack is too deeply nested. Modern compilers can convert tail recursion into a loop to avoid this problem. However, signals and slots will prevent this. This would only be a problem if you are using a DirectConnection for your signals and slots (which would most likely happen automatically). You should make sure that your connections (for the state machine) are QueuedConnections. Especially if the state machine is run inside the main thread a DirectConnection would block the event loop. A QueuedConnection would allow other things to be processed by the event loop as well.
  • Problem transfering app to Raspberry with Qt Creator

    Solved
    7
    0 Votes
    7 Posts
    919 Views
    M
    @Axel-Spoerl I managed to get it working. I utilized the "Override deployment data from build system" option and modified the final step to "Upload files via SFTP" as shown in the image below. [image: e6553330-e4df-4768-ab73-e24b7bdf7673.png] Now, I have a couple of questions: What configurations are required to enable the build system to automatically detect the source and target directories? Is there any documentation available that provides a description of how the deploy files step is utilized? I haven't been able to locate it.
  • Unable to build qt6 using conan package manager and msvc in vscode

    Unsolved
    1
    0 Votes
    1 Posts
    527 Views
    No one has replied
  • Qt app work on boot ubuntu

    Unsolved
    21
    0 Votes
    21 Posts
    3k Views
    A
    @asisisyah first of all thank you so much everyone. i made a "starter.sh" file... than echo nvidia | sudo -S ./myApp ... than start it with startUp Application . its worked. no problem just now thank you so much everyone
  • How to generate .exe from .pro file

    Unsolved
    11
    0 Votes
    11 Posts
    1k Views
    JonBJ
    @Babitha Be aware that QtWebKit was removed from Qt later on Read https://stackoverflow.com/questions/2461799/statically-compiling-qt-4-6-2 and https://forum.qt.io/topic/90051/qtwebkit-cannot-build-qtwebkit-static-for-static-4-8-x-or-5-5-1. Gist is that although some people say they did manage to compile it statically it is apparently "not easy" and also A few people succeeded in making static builds on Windows, however getting linking right is not trivial
  • Detect dark/light mode changes to call update()

    Unsolved
    4
    0 Votes
    4 Posts
    2k Views
    JonBJ
    @buhtz Well it's only a changeEvent() on (subclassed) QMainWindow, not much. But agree it's not vital.
  • How to specify image path in Qt project?

    Unsolved
    3
    0 Votes
    3 Posts
    1k Views
    JonBJ
    @Jsla The problem is that the "project directory" which exists while you develop simply does not "exist" at runtime when you deploy elsewhere/to other people. By which I mean there is no way to "locate" it. You then have 3 choices: Use Qt's QStandardPaths Class to generate a full path to one of the standard directories and use that. The problem is that it's not easy to deploy your file(s) there in the first place,. Use Qt's QCoreApplication::applicationDirPath() to locate where the executable lives. Use that to generate a full path to some images sub-directory from there where the images have been provided. As @SGaist says use Qt's resource system to embed the images into the actual executable and access them there. This is perhaps the easiest, requires you to specify you are using resources at development time.
  • How to find out the camera device ID in the metadata of images and videos?

    Unsolved
    3
    0 Votes
    3 Posts
    3k Views
    D
    @ChrisW67 @ChrisW67 said in How to find out the camera device ID in the metadata of images and videos?: Why can't you believe this? The evidence is right in front of you. The birth time of the file on the Windows file system is whenever you created the file. It has zero to do with the content of the file, or the creation time of the file on any previous system. Its because for all other 45k media files (except for those taken with that one particular gopro camera) QFileInfo f("myfile.jpg"); QDateTime dt = f. metadataChangeTime(); and QFileInfo f("myfile.jpg"); QDateTime dt = f. birthTime(); return identical values and they reflect exactly the time when this media was created. So QFileInfo must somehow have accessed this otherwize the date would be different. @ChrisW67 said in How to find out the camera device ID in the metadata of images and videos?: As for the metadataChangeTime() being before the birthTime(), different by how much? 1 year apart. exactly the time distance btw media recorded and media copied to hard drive. @ChrisW67 said in How to find out the camera device ID in the metadata of images and videos?: You should look at exiftool to see how it might help you. I did integrate the exiftool package into my codde. That is why for jpg only, this is not a problem. But for any other file format, be it video or image, problem is unsolved. But, you just inspired me to invest more time for a solution: maybe if I dedicate more time understanding what exif tool code does in particular and as it simply reads meta data for jpg, maybe I can modify it to read any media file's meta data (provided that I gain full understanding of where the meta data is accessible for each file). I created this bug (actually a suggestion how to improve) which might solve my birth date problem and as QMediaMetaData also can access most if not all meta data once [mediaStatusChanged()](link url) but with delay with which miltithreading cannot live with as described above: [https://bugreports.qt.io/browse/QTBUG-120959](link url)
  • Which ColorRole is usec by ListView?

    Unsolved
    1
    0 Votes
    1 Posts
    117 Views
    No one has replied
  • What is the system under test when doing Qt tests?

    Unsolved
    8
    0 Votes
    8 Posts
    985 Views
    Christian EhrlicherC
    @buhtz said in What is the system under test when doing Qt tests?: So it seems it is not easy to reach complete code coverage for Qt code using tests. If it's only your code which has full coverage I don't see why it should not be possible.
  • I create a QPushButton instance before ui->setupUi(this), And this button wont clicked

    Moved Unsolved
    4
    0 Votes
    4 Posts
    361 Views
    Axel SpoerlA
    @NULL_NULL m_buttonis directly parented to MainWindow, which at this point doesn't have a central widget. That's added (amongst other things) in setupUi(). Hard to say where and why exactly things go wrong, but it's somewhere there. It'll be better to construct the button without a parent in the first place: , m_button(new QPushButton("KSKSKSKSK")) You can add it after calling setupUi(), e.g. with m_button->setParent(centralWidget()); or by adding it to a layout with ui->anyLayout->addWidget(m_button);
  • QVariant error but I'm not using QVariant

    Solved
    4
    0 Votes
    4 Posts
    648 Views
    W
    @Axel-Spoerl Ah yes that was it, thanks. Stay warm...
  • Drawing a triangle doesn't work on laptop Asus K53SV with Mesa using Qt 6.7.0 beta1

    Solved
    3
    0 Votes
    3 Posts
    386 Views
    8Observer88
    @Christian-Ehrlicher Thanks a lot! You are right! I forgot to activate (bind) the program in paintGL(): void paintGL() override { m_program.bind(); glClear(GL_COLOR_BUFFER_BIT); glDrawArrays(GL_TRIANGLES, 0, 4); } [image: 69d1a505-0c96-4e98-b236-54dc8cdf047f.png] pro QT += core gui openglwidgets widgets win32: LIBS += -lopengl32 CONFIG += c++17 SOURCES += \ main.cpp main.cpp #include <QtGui/QOpenGLFunctions> #include <QtGui/QSurfaceFormat> #include <QtOpenGLWidgets/QOpenGLWidget> #include <QtOpenGL/QOpenGLBuffer> #include <QtOpenGL/QOpenGLShaderProgram> #include <QtWidgets/QApplication> class OpenGLWidget : public QOpenGLWidget, private QOpenGLFunctions { public: OpenGLWidget() { resize(350, 350); setWindowTitle("OpenGL Triangle"); } private: void initializeGL() override { initializeOpenGLFunctions(); glClearColor(0.4f, 0.8f, 0.9f, 1.f); qDebug() << "OpenGL Version:" << (const char*) glGetString(GL_VERSION); qDebug() << "GLSL Version:" << (const char*) glGetString(GL_SHADING_LANGUAGE_VERSION); qDebug() << "OpenGL Vendor:" << (const char*) glGetString(GL_VENDOR); QString vertexShaderSource = "attribute vec2 aPosition;\n" "void main()\n" "{\n" " gl_Position = vec4(aPosition, 0.0, 1.0);\n" "}\n"; QString fragmentShaderSource = "#ifdef GL_ES\n" "precision mediump float;\n" "#endif\n" "//out vec4 fragColor;\n" "void main()\n" "{\n" " gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);\n" "}\n"; m_program.create(); m_program.addShaderFromSourceCode(QOpenGLShader::ShaderTypeBit::Vertex, vertexShaderSource); m_program.addShaderFromSourceCode(QOpenGLShader::ShaderTypeBit::Fragment, fragmentShaderSource); m_program.link(); m_program.bind(); float vertPositions[] = { -0.5f, -0.5f, 0.5f, -0.5f, 0.f, 0.5f }; m_vertPosBuffer.create(); m_vertPosBuffer.bind(); m_vertPosBuffer.allocate(vertPositions, sizeof(vertPositions)); m_program.setAttributeBuffer("aPosition", GL_FLOAT, 0, 2); m_program.enableAttributeArray("aPosition"); } void paintGL() override { m_program.bind(); glClear(GL_COLOR_BUFFER_BIT); glDrawArrays(GL_TRIANGLES, 0, 4); } private: QOpenGLShaderProgram m_program; QOpenGLBuffer m_vertPosBuffer; }; int main(int argc, char *argv[]) { QApplication app(argc, argv); OpenGLWidget w; w.show(); return app.exec(); }
  • How can divide QTabWidget into multiple lines?

    4
    0 Votes
    4 Posts
    5k Views
    SGaistS
    Hi, To add to @andre, if you have that many tabs, you might want to consider refactoring your UI. Take for example the preferences of Qt Creator, the tabs are grouped by themes and you have a list view on the left to change the theme.
  • QDesktopWidget gone

    Solved
    2
    0 Votes
    2 Posts
    591 Views
    Christian EhrlicherC
    @whatabout said in QDesktopWidget gone: I was using to get the screen's DPI. See QScreen.
  • QPSQL driver not loaded

    Solved
    5
    0 Votes
    5 Posts
    636 Views
    JonBJ
    @OniFloppa Some programs only work on certain days (especially under Windows).... ;)
  • Application won't always start

    Solved
    7
    0 Votes
    7 Posts
    574 Views
    T
    Found the problem. It was uninitialized variable in another class that was constructed in the constructor of MainWindow, causing for loop to go to to 2^32 or other random number. Sorry for taking your time for this. The Before MainWindow... was NOT always printed. It may have to do with flushing of the data in the system. I will continue monitoring but it looks good for the moment.
  • Postgresql Return no value

    Solved
    4
    0 Votes
    4 Posts
    716 Views
    Christian EhrlicherC
    @John-Hon said in Postgresql Return no value: that I can miss You simply did not read the documentation on how it works. QSqlQuery::exec() executes the query, the data is fetched with QSqlQuery::next().
  • How can I make sure that paintEvent has finished?

    Unsolved
    5
    0 Votes
    5 Posts
    446 Views
    Axel SpoerlA
    @JamalNewtron said in How can I make sure that paintEvent has finished?: Is there any option to get to know when the screen has been flushed? My Windows knowledge is very limited. From what I know, things a pretty synchronous on Windows. The issue you experience is not Qt related. It applies to all windows in Windows.
  • new class inherited from QLabel not showing in parent window

    Unsolved
    3
    0 Votes
    3 Posts
    276 Views
    H
    @Paul-Colby that's what it was! thank you!!