Skip to content

Qt 6

This is where all Qt 6 related questions belong

872 Topics 4.3k Posts
  • Question for Qt6.2 - Qt.labs.platform Dialog

    Unsolved
    6
    0 Votes
    6 Posts
    1k 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
    506 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
    2k 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
  • Seeking Information about Qt Modules that I can't understand from the docs

    Unsolved
    2
    0 Votes
    2 Posts
    421 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
  • Seeking plugin information

    Solved
    3
    0 Votes
    3 Posts
    441 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?
  • Allocation of incomplete type "Ui::MainWindow"

    Solved error uimainwindow.h incomplete type mainwindow
    9
    0 Votes
    9 Posts
    12k Views
    SGaistS
    @TrahdBoy hi, It's all explained here.
  • Access to my camera not granted.

    Solved
    4
    0 Votes
    4 Posts
    1k 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
    761 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
    796 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
    948 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
    2k 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
    575 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
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    3 Views
    No one has replied
  • SIGSEGV QtPrivate::QMetaTypeInterfaceWrapper<QFlagsQt::WindowState >::metaType ()

    Unsolved
    4
    0 Votes
    4 Posts
    520 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.
  • Could you please help me with some modifications to my Qt6 code?

    Unsolved
    8
    0 Votes
    8 Posts
    1k Views
    T
    Have you solved this problem yet? I'm having the same problem trying QT6!
  • QT6 run the .exe but point out "lack of libwinpthread-1.dll"

    Solved
    6
    0 Votes
    6 Posts
    1k Views
    pedisChenP
    @jsulm I understand now,thank you
  • This topic is deleted!

    Unsolved
    12
    0 Votes
    12 Posts
    79 Views
  • Qcache a buggy class?

    Unsolved
    9
    0 Votes
    9 Posts
    1k Views
    kshegunovK
    @FeRDNYC said in Qcache a buggy class?: ...Or I suppose the docs could have a general explainer page about object ownership and lifetimes, which statements like the one quoted above are linked to. Devs moving from garbage-collected languages, in particular, don't necessarily have that background. Qt is a library, and as @Christian-Ehrlicher mentioned, it's not any library's concern to teach you the underlying language - it is assumed that you're going to be using the library after you understand the basis of its existence. I can see how if you are coming from a garbage-collected language this may sound unfair, but if you think about it for a while I think you'd agree that C++ is too large and too complex for you to require from Qt (developers) to feed you information about the language too. Note: I'm liberally using "you", but do consider it as using the indefinite pronoun form.
  • Qt for ios save file error? why?

    Unsolved qt for ios save file error
    5
    0 Votes
    5 Posts
    724 Views
    K
    @jsulm Hello, I found that I need to use oc and qt for mixed compilation, but I can't add the Foundation framework in cmake. How should I add it? I checked the information and he said that iOS can only read and write at the location "QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation).last()"