Skip to content

Qt 6

This is where all Qt 6 related questions belong

809 Topics 3.9k Posts
QtWS25 Call for Papers
  • Read before posting in this category!

    Pinned Locked
    3
    6 Votes
    3 Posts
    2k Views
    SGaistS

    And now (incomplete at the time of this post): https://wiki.qt.io/New_Features_in_Qt_6.2

  • Bluetooth not working In Qt 6

    Unsolved
    6
    0 Votes
    6 Posts
    88 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
    661 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
    50 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
    531 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

  • Windows11 native appearance question

    Unsolved
    1
    0 Votes
    1 Posts
    74 Views
    No one has replied
  • 0 Votes
    2 Posts
    72 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
    175 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
    62 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
    9k Views
    SGaistS

    @TrahdBoy hi,

    It's all explained here.

  • Access to my camera not granted.

    Solved
    4
    0 Votes
    4 Posts
    119 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
    158 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
    112 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
    166 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
    160 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
    223 Views
    M

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

  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    10 Views
    No one has replied
  • 0 Votes
    1 Posts
    110 Views
    No one has replied
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    3 Views
    No one has replied
  • 0 Votes
    4 Posts
    117 Views
    Axel SpoerlA

    When you post code, please use the code formatting tags. It makes reading much easier for those who help you.
    I have never bumped into an error like that. Probably there is something wrong in how this QAIM is instantiated and d is either stale or nullptr.