Skip to content

Qt 6

This is where all Qt 6 related questions belong

827 Topics 4.0k Posts

QtWS: Super Early Bird Tickets Available!

  • Could not find a configuration file

    Unsolved
    8
    0 Votes
    8 Posts
    417 Views
    jsulmJ

    @Kais-Ahmad Are you by any chance mixing MSVC and MinGW? MinGW Qt build requires GLibC.

  • Painting a QVideoFrame on a QVideoWidget with QT6

    Solved
    5
    0 Votes
    5 Posts
    1k Views
    F

    For those who are digging the depths of the internet to do this in Python, I figured out a way. It looks like the Python docs are wrong and/or ambiguous: "The video frame can then be used to read out the data of those frames and handle them further. When using QPainter, the QVideoFrame can be drawing using the paint() method in QVideoSink ."

    I'm not a professional programmer so this may be ugly/non-conforming for some people but this works:

    You can set the QMediaCaptureSession's video sink to your custom sink, and also make a QVideoWidget to display the frames. Then, take that custom sink, and connect some Slot method to the videoFrameChanged Signal, and inside that method do what you need to the frame, and then you can take that frame and use QVideoWidget.videoSink().setVideoFrame(the frame you just modified) and it works like a charm.

    Please respond if this is unclear.

    PS: mods/admins if this is in the wrong place please let me know.

  • 0 Votes
    3 Posts
    139 Views
    Pl45m4P

    @Damned-Ananas

    The code you show does not work as the three QLabels are not part of any layout.
    So setting

    hLayout->setStretch(0, 1); hLayout->setStretch(1, 1); hLayout->setStretch(2, 4);

    does not affect the labels, unless you are doing something else which you did not show.

    And, as @JonB said above, until the layouts are applied and the widget is shown, you can't trust the widget's geometry you receive from geometry(), width() or height() as these values are generic/default values based on your settings and not how the widget actually looks when being rendered in some window or parent widget.

    So please show your complete/actual code (and/or try what @JonB suggested)

  • 0 Votes
    2 Posts
    220 Views
    M

    Hello,
    Unfortunately, there's no direct way to determine if your fragment shader is running within a Qt application or environment using built-in preprocessor directives or variables.
    Understanding the Limitations
    Shader Isolation: Shaders operate in a relatively isolated environment, with limited access to the surrounding application context.
    Platform-Specific Information: Information about the application environment is typically handled at a higher level, outside the shader's scope.

  • Windows11 native appearance question

    Unsolved
    2
    0 Votes
    2 Posts
    291 Views
    I

    I also have the same issue, and cannot find anyone else complaining. I don't have a solution for you though.

    I recently transitioned from 6.6.1 to 6.7.2. And the "windows11" style in light mode looks hideous. There is less contrast throughout the application, making it difficult to navigate. Some bits are nice, but most are bad. The silver lining is that dark mode is better than the previous Fusion style, especially checkboxes. In light mode, I'm setting the style to "windowsvista" to achieve 6.6.1 look for now.

  • Qt to Sql connection

    Unsolved
    3
    0 Votes
    3 Posts
    128 Views
    JonBJ

    @Chakravarthi-N
    Same as it has always been. Have you started by reading SQL Programming and Connecting to Databases?

  • Bluetooth not working In Qt 6

    Unsolved
    6
    0 Votes
    6 Posts
    293 Views
    M

    @JonB @Q-Master @Qt-Enthusiast @Qt-embedded-developer I have this configuration use for msvc compiler and i have run different project that perfectly run with this configuration

    image.png

  • Question for Qt6.2 - Qt.labs.platform Dialog

    Unsolved
    6
    0 Votes
    6 Posts
    820 Views
    J

    because the qt.labs.platform has the Dialog as well, need to specifically use Dialog control in QtQuick.Controls

  • Is there any change in the licensing from qt5 to qt6?

    Unsolved
    2
    0 Votes
    2 Posts
    173 Views
    jsulmJ

    @Vishal-Kumar said in Is there any change in the licensing from qt5 to qt6?:

    Is there any change happened to qt6 opensource licensing which might cause an issue later ?

    As far as I know there are no changes since Qt 5.6 (where LGPL was changes to v3).

  • [Custom Background for a widget]

    Unsolved
    12
    0 Votes
    12 Posts
    851 Views
    B

    I am also having the same behavior:

    If this is my custom widget that is derived from QWidget:

    CCustomWidget.h namespace Ui { class CCustomWidget; } class CCustomWidget : public QWidget { Q_OBJECT public: explicit CCustomWidget(QWidget* pParent = nullptr); ~CCustomWidget(); private: Ui::CCustomWidget* ui; }; CCustomWidget.cpp #include "CCustomWidget.h" #include "ui_CCustomWidget.h" CCustomWidget::CCustomWidget(QWidget* pParent) : QWidget(pParent), ui(new Ui::CCustomWidget) { ui->setupUi(this); } CCustomWidget::~CCustomWidget() { delete ui; } main.cpp #include <QApplication> #include "CCustomWidget.h" int main(int argc, char* argv[]) { QApplication App(argc,argv); // this does not load the image CCustomWidget CW; CW.setStyleSheet(QStringLiteral("background-image: url(:/background.png);")); CW.show(); // this does load the image // QWidget W; // W.setStyleSheet(QStringLiteral("background-image: url(:/background.png);")); // W.show(); return App.exec(); }

    When I am in the Designer tab of QtCreator, the background image for my custom widget displays correctly. But as soon as I compile/run the program. The custom widget no longer has a background image.

    I have tried:

    Programmatically setting the style sheet (as above) Setting the style sheet in the Designer of QtCreator Specifying my custom widget in the style sheet definition, where myCustomWidget is the QObject name that I set for my class in the constructor. CW.setStyleSheet("#myCustomWidget{ background-image: url(:/background.png); }");

    I finally resorted to adding a QWidget on the Designer tab of QtCreator. Setting its style sheet to the background image by setting it in the properties section, and then moving the widget to the back so that it is behind everything else on the custom widget.

    There is clearly something fundamental that I am missing but I do know know what it is or what even to ask. If someone could point me in the right direction, I would greatly appreciate it. It seems like setting a custom background image for your custom widget should be something that is very easy to do, but it is eluding me.

    Thanks

  • 0 Votes
    2 Posts
    161 Views
    A

    Hi,

    The answer is pretty simple: only use the templates for property declaration. If you don't, you may get the incompatible type error. The templates are also used to implement themes like Material or Universal theme.

    Instead of doing

    import QtQuick import QtQuick.Controls Item { id: root property Button myButton: Button {} }

    You must use the Button type provided by the Templates

    import QtQuick import QtQuick.Controls import QtQuick.Templates as T Item { id: root property T.Button myButton: Button {}

    And they're used to defining the visual types

    // Copyright (C) 2017 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only import QtQuick import QtQuick.Templates as T import QtQuick.Controls.impl import QtQuick.Controls.Material import QtQuick.Controls.Material.impl T.Button { id: control implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset, implicitContentWidth + leftPadding + rightPadding) implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, implicitContentHeight + topPadding + bottomPadding) topInset: 6 bottomInset: 6 verticalPadding: Material.buttonVerticalPadding leftPadding: Material.buttonLeftPadding(flat, hasIcon && (display !== AbstractButton.TextOnly)) rightPadding: Material.buttonRightPadding(flat, hasIcon && (display !== AbstractButton.TextOnly), (text !== "") && (display !== AbstractButton.IconOnly)) spacing: 8 icon.width: 24 icon.height: 24 icon.color: !enabled ? Material.hintTextColor : (control.flat && control.highlighted) || (control.checked && !control.highlighted) ? Material.accentColor : highlighted ? Material.primaryHighlightedTextColor : Material.foreground ...

    https://github.com/qt/qtdeclarative/blob/dev/src/quickcontrols/material/Button.qml

    And make sure to read this section. It explains why you must use templates when declaring properties: https://doc.qt.io/qt-6/qtquick-controls-qmlmodule.html#using-qt-quick-controls-types-in-property-declarations

  • 0 Votes
    6 Posts
    338 Views
    SGaistS

    You could write a feature request for that. CMake has a limited support for handling that file but AFAIK, nothing as complete as you would need.
    Thanks for your kind words.

  • Seeking plugin information

    Solved
    3
    0 Votes
    3 Posts
    153 Views
    Ash VA

    @jsulm

    Hi. Could you please name the specific one in that list of Qt Quick? :)
    Or I need to turn on all of them?

  • 0 Votes
    9 Posts
    10k Views
    SGaistS

    @TrahdBoy hi,

    It's all explained here.

  • Access to my camera not granted.

    Solved
    4
    0 Votes
    4 Posts
    436 Views
    W

    Hello,
    Here I answer this question by myself, hope my answer can help someone who also meets this issue.

    Set QMAKE_INFO_PLIST in your pro file.
    Please refer https://doc.qt.io/qt-6/ios-platform-notes.html#info-plist-with-qmake

    Make one function to check camera permission.
    For example,
    void MainWindow::checkCameraPermission(void)
    { // please refer https://code.qt.io/cgit/qt/qtmultimedia.git/tree/examples/multimedia/camera?h=6.7
    #if QT_CONFIG(permissions)

    QCameraPermission cameraPermission;
    switch (qApp->checkPermission(cameraPermission)) {
    case Qt::PermissionStatus::Undetermined:
    qApp->requestPermission(cameraPermission, this, &MainWindow::checkCameraPermission);
    return;
    case Qt::PermissionStatus::Denied:
    std::cout << "Camera permission is not granted!" << std::endl;
    return;
    case Qt::PermissionStatus::Granted:
    std::cout << "Camera permission is granted!" << std::endl;
    break;
    }

    #endif
    }

    Make one function to check camera permission status.
    For example,
    void MainWindow::checkAuthorizationStatus(void)
    {
    #if QT_CONFIG(permissions)

    QCameraPermission cameraPermission;
    Qt::PermissionStatus auth_status = Qt::PermissionStatus::Undetermined;
    while(true)
    {
    QThread::msleep(1);
    auth_status = qApp->checkPermission(cameraPermission);

    if(auth_status == Qt::PermissionStatus::Undetermined) continue; break;

    }

    #endif // if QT_CONFIG
    }

    Before searching your camera, call the following functions,
    checkCameraPermission();
    checkAuthorizationStatus();

    At my side, this issue had been solved.

    Thanks.
    Have a nice day.

  • how can I deploy my own static library?

    Solved
    7
    0 Votes
    7 Posts
    284 Views
    W

    @SimonSchroeder

    This is a good idea.
    I will try it.
    Thanks.
    Have a nice day.

  • Missing shared objects while using system Qt

    Unsolved
    8
    0 Votes
    8 Posts
    261 Views
    jsulmJ

    @Ash-V What is your Linux distribution?

  • How can I connect my QT cmake project to LibXL

    Unsolved
    9
    0 Votes
    9 Posts
    375 Views
    Christian EhrlicherC

    @Mihil-Ranasinghe said in How can I connect my QT cmake project to LibXL:

    was using QXlsx library it was shown in project tree.

    You did not - you just added the sources to your project instead linking to an external library - these are two completely different things.

  • Can't find QT6 inserts to satisfy Wayland

    Unsolved
    4
    0 Votes
    4 Posts
    531 Views
    SGaistS

    Start the application with the QT_DEBUG_PLUGINS environment variable set to 1 to see why it fails to load.

  • 0 Votes
    2 Posts
    299 Views
    M

    Delete the qbs build directory in your project after exiting QtCreator and build it again