qt_reddit | Unsorted

Telegram-канал qt_reddit - Qt - Reddit

-

News and discussion for the Qt Framework. Subreddit: https://www.reddit.com/r/QtFramework Powered by : @r_channels & @reddit2telegram

Subscribe to a channel

Qt - Reddit

How To Integrate Visual ToolKit (VTK) in Qt and QML

For anyone who is struggling to setup the Visual Toolkit (VTK)-an open source software used extensively in Medical Imaging and Data Visualization- for integration in Qt and QML, I have written a guide on Medium. I hope you find it useful.



https://amireza007.medium.com/how-to-integrate-vtk-in-qt-and-qml-7ac657e463ac



If you found it useful, please consider clapping and sharing, and if you did find any mistakes, let me know to fix them ASAP.

Cheers

https://redd.it/1f9l1dj
@qt_reddit

Читать полностью…

Qt - Reddit

How can a bring a constant stream of command output to a QWidget (QTextbrowser)?

I only know how to set the text after the command is finished, but I need a live feed so the user can tell if something is stuck.

https://redd.it/1f8jhm6
@qt_reddit

Читать полностью…

Qt - Reddit

        onExited: {
                            sideBar.isAnyItemHovered = false
                            hoverTimer.restart()
                        }
                        onClicked: {
                            sideBar.selectedItem = modelData.text
                            appArea.loadPage(modelData.text)
                            print(modelData.text + " clicked")
                        }
                    }

                }
            }
        }
    }

    Rectangle {
        id: topBar
        anchors.left: sideBar.right
        anchors.top: parent.top
        height: 30
        width: parent.width
        color: App.Theme.primary
    }

    Rectangle {
        id: appArea
        anchors.left: sideBar.right
        anchors.top: topBar.bottom
        height: parent.height - topBar.height + 10
        width: parent.width - sideBar.width + 10
        color: App.Theme.lightNeutral
        radius: 10 // Added rounded corners
        Loader {
            id: pageLoader
            source: "qrc:/Apps/Contacts.qml"
        }

        function loadPage(page) {
            switch (page) {
                case "Contacts":
                    pageLoader.source = "qrc:/Apps/Contacts.qml"
                    break
                case "Companies":
                    pageLoader.source = "qrc:/Apps/Companies.qml"
                    break
                case "Tickets":
                    pageLoader.source = "qrc:/Apps/Tickets.qml"
                    break
                case "Reports":
                    pageLoader.source = "qrc:/Apps/Reports.qml"
                    break
                default:
                    console.log("Unknown page:", page)
                    pageLoader.source = "qrc:/Apps/Contacts.qml" // Or set to a default page
                }
        }
    }
}

Here's my output error

QQmlApplicationEngine failed to load component
qrc:/main.qml:4:1: "qrc:/Theme.qml": no such directory
Failed to load QML file

https://redd.it/1f7f42c
@qt_reddit

Читать полностью…

Qt - Reddit

QML Resource Packaging Issues

I'm developing a QML application using Pyside6 and am having issues with linking my [main.py](http://main.py) and main.qml file to other QML files. Here's the project repository: [HubSpot-Clone](https://github.com/cbhirsch/HubSpot-Clone.git)

So I've had issues with packaging my Companies.qml Contacts.qml Reports.qml Tickets.qml files so that I can load them into the main window. I have even had issues with the Theme.qml file only able to get it to load using the command

import "." as Apps

QML has been working great for me accept for the packaging issues. Does anybody have any feedback?

Current directory is using a full directory path but I have also used "qrc:/main.qml" for the paths. I'm at a loss at this point.

Here's what I am currently trying using the q resource system in my main.qml code:

import QtQuick 2.15
import QtQuick.Window 2.15
import QtQuick.Layouts 2.15
import "qrc:/Theme.qml" as App

Window {
    width: Screen.width
    height: Screen.height
    color: App.Theme.primary
    visible: true
    title: qsTr("Demo")

    Rectangle {
        id: sideBar
        anchors.top: parent.top
        anchors.left: parent.left
        color: App.Theme.primary
        height: parent.height
        width: isExpanded ? 150 : 50

        property bool isExpanded: false
        property string selectedItem: ""
        property bool isSidebarHovered: false
        property bool isAnyItemHovered: false
       

        Behavior on width {
            NumberAnimation { duration: 200 }
        }

        Timer {
            id: hoverTimer
            interval: 50 // Short delay to prevent rapid toggling
            onTriggered: {
                sideBar.isExpanded = sideBar.isSidebarHovered || sideBar.isAnyItemHovered
            }
        }

         MouseArea {
            anchors.fill: parent
            hoverEnabled: true
            onEntered: {
                sideBar.isSidebarHovered = true
                hoverTimer.restart()
            }
            onExited: {
                sideBar.isSidebarHovered = false
                hoverTimer.restart()
            }
        }


        ColumnLayout {
            id: sideBarContent
            anchors.left: parent.left
            anchors.top: parent.top
            anchors.right: parent.right
            spacing: 10

            Rectangle {
                id: logo
                width: sideBar.width
                height: 50
                color: "transparent"
                Item{
                    //spacing: 10
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.left: parent.left
                    anchors.leftMargin: 10

                    Image {
                        source: "qrc:/icons/Hubspot_logo.png"
                        width: 24
                        height: 24
                    }
                }
            }
       
            Rectangle {
                id: crmDisplay
                width: sideBar.width - 10
                height: 40
                color: "transparent"

                Item {
                    //spacing: 10
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.left: parent.left
                    anchors.leftMargin: 10

                    Image {
                        id:crmIcon
                        source: "qrc:/icons/grid_view_32dp_F0F5F9.png"
                        width: 24
                        height: 24
                        anchors.verticalCenter: parent.verticalCenter
                    }

                    Text {
                        text: "CRM"
                     

Читать полностью…

Qt - Reddit

Introducing QodeAssist: Your Private Code Assistant for QtCreator

I'm introducing QodeAssist (https://github.com/Palm1r/QodeAssist), an open-source plugin that integrates AI-assisted coding into QtCreator while prioritizing privacy and local execution.

# Key Features:

LLM-powered code completion
Local execution using models like StarCoder2, CodeLlama, DeepSeekCoderV2
Privacy-focused: code stays on your machine
Seamless QtCreator integration
Support for multiple LLM providers (Ollama, LM Studio, OpenAI API compatible)

# Technical Overview:

Built with QtCreator's plugin API and Language Server Protocol
Uses Fill-in-the-Middle (FIM) for context-aware suggestions
Extensible architecture for various AI providers

The project is open for contributions and feedback. Visit the GitHub repository for more information or to get involved.

https://redd.it/1f7b2eb
@qt_reddit

Читать полностью…

Qt - Reddit

Ring 1.21 is released!

What is new in Ring 1.21 — Ring 1.21 documentation (ring-lang.github.io)

https://redd.it/1f6nzbv
@qt_reddit

Читать полностью…

Qt - Reddit

Problems with qmldesigner.

I'm trying to start developing apps with quickquick/qml using qtcreator, but the qtcreator doesn't start with QmlDesigner extension loaded it just throws some kind of sqlite error.

$ qtcreator -test QmlDesigner
terminate called after throwing an instance of 'Sqlite::StatementHasError'
what(): Sqlite::StatementHasError: incomplete inputSessions(
Aborted

And I can't find anyone else having same problem on internet.

I tried building from source and installing qtcreator from maintanence tool, but nothing works.

Is there alternative software for designing .qml files or guide how to use qtcreator and design studio together. Or do I just have to make the UI by code?

I'm using Artix Linux(arch linux with openrc) with X11.

https://redd.it/1f5vomb
@qt_reddit

Читать полностью…

Qt - Reddit

Issue with QT interop with glib's dbus. Someone please explain. Linux - C++

I have 2 processes, UI and backend, which communicate through the DBus.

# Issue

My QT based UI application becomes irresponsive when a DBus message comes in. Reason: The DBus message handler runs in the main thread not in the thread where the \`GMainLoop\` was created. It clogs the main thread and QT cannot process events on that thread.

But - The backend which in non QT runs dbus message handlers in a separate thread than the main thread.

# What Fixed This

// changing this
mainloop = g_main_loop_new(nullptr, false);
dbus_connection_setup_with_g_main(dbus_conn, nullptr);
// to this
GMainContext *rpc_server_context = g_main_context_new();
g_main_context_push_thread_default(rpc_server_context);
mainloop = g_main_loop_new(rpc_server_context, false);
dbus_connection_setup_with_g_main(dbus_conn, rpc_server_context);

# My understanding

Qt has it's own event loop and I originally created a new event loop (GMainLoop) with null context. GMainLoop sees null as context and starts using main thread context.

It then pushes the DBus message handlers into the main thread's stack. Until the the dbus handler is running Qt cannot process any events, as it processes them on main thread so the application becomes irresponsive.

This logic works well with my UI application where dbus handerls were running in parent thread (main thread) when null context was used. But why the hell my messages handlers were working in the child thread (dbus servre thread) as expected??

>I cannot understand this part? Where is the gap in my understtanding?

# Implementation Details

Both processes have same implementation of the DBus server, which is as follows:

\* DBus server is a singleton which extends \[Poco::Runnable\](https://docs.pocoproject.org/current/Poco.Runnable.html)

\* Main thread starts and stops the server

\* \`startServer\` creates a new thread and DBus server's \`run()\` runs in that new thread

\* \`stopServer\` stops the server and joins the thread.

# Implementation of DBusServer::run()

The code which runs in a separate thread.

// DBusServer::run()
// [DBus connection code]
// GMainLoop creation
mainloop = g_main_loop_new(nullptr, false);
dbus_connection_setup_with_g_main(dbusConnection, nullptr);
// Will be unset by stopServer() from main thread
keepMonitoring = true;
while(keepMonitoring) {
g_main_loop_run(mainloop);
}
// [Clean up code]

\*\*TL;DR:\*\* Glib's dbus server was running the message handlers in the same thread but it is pushing them into to main thread where Qt application is running which freezes the QT application's UI

https://redd.it/1f5pwq0
@qt_reddit

Читать полностью…

Qt - Reddit

How to re-use Qt/Qml WebEngineView for multiple url's

So I am using WebEngineView within qml to create a sort of google workspace app I have it working but have to use multiple instances of WebEngineView, not efficient as it loads about 16 copies of WebEngineView into memory here is the code

I see in the docs about WebEngineNewViewRequest but can't seem to find a working example of how to implement it

in theory it seems i can use one WebEngineView with multiple views and ability to switch views to display that view's web url w/o reloading the url everytime i switch to it... using something like this NewViewDestination : WebEngineView.NewViewInDialog

what i can't figure out is how to use it in a function so that when navbar icon is clicked it loads view?

Tried over at stackoverflow, but no responses, so i thought i would give reddit a try at this

Any help/ideas appreciated

Thanks

https://redd.it/1f4hnxn
@qt_reddit

Читать полностью…

Qt - Reddit

cb->resourceUpdate(batch);
}

}

void SmileFaceRenderer::render(QRhiCommandBuffer *cb)
{
...
...

QRhiResourceUpdateBatch *batch = m_rhi->nextResourceUpdateBatch();
cb->beginPass(renderTarget(), Qt::white, { 1.0f, 0 }, batch);

const QRhiCommandBuffer::VertexInput vbufBindings[] = {
{ m_vectexBuffer.get(), 0 },
{ m_modelBuffer.get(), 0 }
};
cb->setVertexInput(0, 2, vbufBindings);

// update the 2 graphics's model matrixes
for (int i = 0; i < m_instances; i ++) {
QMatrix4x4 model;
model.setToIdentity();


// the rectangle position to right middle
if (i == 0) {
model.translate(400, 0, 0);
}

// the triangle position to top middle
if (i == 1) {
model.translate(0, 400, 0);
}
batch->uploadStaticBuffer(m_modelBuffer.get(),
i * sizeof(float) * 16,
sizeof(float) * 16,
model.constData());
}

cb->resourceUpdate(batch);
cb->setShaderResources(m_srb.get());

// draw the rectangle,
// first vectex from 0 in vbo,
// first instance is 0
cb->draw(6, 1, 0, 0);

// draw the triangle,
//first vectex from 6 in vbo,
// first instance is 1
cb->draw(3, 1, 6, 1);

cb->endPass();


}

// vertex shader code
#version 440

layout(location = 0) in vec4 position;
layout(location = 1) in vec3 color;
layout(location = 2) in vec4 aMatCol0;
layout(location = 3) in vec4 aMatCol1;
layout(location = 4) in vec4 aMatCol2;
layout(location = 5) in vec4 aMatCol3;

layout(std140, binding = 0) uniform viewProjectionBlock {
mat4 view;
mat4 projection;
};

layout(location = 0) out vec3 v_color;

void main()
{
v_color = color;
mat4 model = mat4(aMatCol0, aMatCol1, aMatCol2, aMatCol3);
gl_Position = projection * view * model * position;
}

Performance of macOS

https://preview.redd.it/n2u2w3zxobld1.png?width=2560&amp;format=png&amp;auto=webp&amp;s=0d148c61c3c67434787207f1631f7514a51d9c4d

Performance of Windows

https://preview.redd.it/j26n2vi0pbld1.png?width=1642&amp;format=png&amp;auto=webp&amp;s=bdb61abc09ed0a73e0016d1d5b534cc17e4a689f


On macOS, both graphics appear in the position defined by their respective model matrices.

On Windows, it looks like the second graphic uses the first model matrix, and the second model matrix cannot be read with the instance.

Any good suggestions?

https://redd.it/1f308dw
@qt_reddit

Читать полностью…

Qt - Reddit

My QT App. It predicts vehicle fuel consumption with artificial intelligence.
https://github.com/BerkKilicoglu/Fuel-Consumption-Estimator

https://redd.it/1f2ibk9
@qt_reddit

Читать полностью…

Qt - Reddit

QML : Drag and Drop with Gridview

hi friends, I am trying to implement drag and drop for my Gridview to give the user the ability to re-order item in Gridview, but there are many problems with it, do you guys have a minimal working example that works for me as a starting point?

https://redd.it/1f1oikv
@qt_reddit

Читать полностью…

Qt - Reddit

Table/TreeView with heterogeneous content delegates

Hi,

Let's say you have to implement a property browser with a QML TreeView. There is a lot of property types (a lot, maybe 50), and each type has a dedicated widget type to edit the property value.

The standard solution is to use DelegateChooser and 1 DelegateChoice per property type. The problem is, you have to type TreeViewDelegate {...} for every choice, and it's cumbersome, especially when you have more than 10 choices. It's boring to write and boring to read. However, you can't omit TreeViewDelegate because you want a proper cell background that reacts to selection.

I wrote a solution to this problem below.

Pros: it works. The DelegateChooser for property editors can be moved to its own file, and it's fast to add more choices.

Cons: instantiating a dummy Repeater with a dummy model for each cell seems awful to me, even if QQuickTableView instantiates only visible items.

Has anyone tried to solve the same problem?

Thanks and have a nice day.


TreeView {
model: theModel // theModel provides a bunch of rows and a "type" data role.
delegate: DelegateChooser {
DelegateChoice {
column: 0

TreeViewDelegate {
id: labelDelegate

contentItem: Label {
// Yeah, the property label is dummy.
text: parent.row
}
}
}

DelegateChoice {
column: 1

TreeViewDelegate {
id: editorDelegate

required property int type

contentItem: Repeater {
model: QtObject {
readonly property int type : editorDelegate.type
}
delegate: DelegateChooser {
role: "type"

DelegateChoice {
roleValue: 0
Button {}
}
DelegateChoice {
roleValue: 1
SpinBox {}
}
DelegateChoice {
roleValue: 2
CheckBox {}
}
DelegateChoice {
roleValue: 3
ComboBox {}
}
}
}
}
}
}
}

https://redd.it/1f09gb2
@qt_reddit

Читать полностью…

Qt - Reddit

QSerialPort readyRead signal not emitted if port opened during WM_DEVICECHANGE event

My application attempts to automatically detect/connect to specific serial ports when the target device is connected/disconnectd from my Windows 11 machine. I'm using a \`QAbstractNativeEventFilter\` to monitor for WM\_DEVICECHANGE notifications and then handling the DBT\_DEVICEARRIVAL and DBT\_DEVICEREMOVECOMPLETE to determine when to open/close the port.

Unfortunately what I'm finding is that when I open a port after a device arrives, the readyRead signal is not emitted. If the port is already present when the application starts, the readyRead signal is emitted as expected. I'm not seeing any errors nor does the \`open\` function return an error.

If I subsequently close my application and open the same port in another application like RealTerm, data is received as expected.

Any thoughts, please?

Here's some snippets of code which might be useful:

**SerialPortDeviceEventFilter.cpp:**

bool SerialPortDeviceEventFilter::nativeEventFilter(const QByteArray &eventType, void *message, long *result)
{
/* get the message */
MSG* msg = reinterpret_cast<MSG*>(message);

if (msg->message == WM_DEVICECHANGE) {
DEV_BROADCAST_HDR* hdr = reinterpret_cast<DEV_BROADCAST_HDR*>(msg->lParam);

if (hdr->dbch_devicetype == DBT_DEVTYP_PORT) {
/* serial port */
DEV_BROADCAST_PORT* port = reinterpret_cast<DEV_BROADCAST_PORT*>(msg->lParam);

/* get the port name */
QString portName = QString::fromWCharArray(port->dbcp_name);
QSerialPortInfo info(portName);

qDebug() << "VID: " << info.vendorIdentifier()
<< "PID: " << info.productIdentifier();

/* validate the vid and pid against the polly */
if (info.vendorIdentifier() == VendorId && info.productIdentifier() == ProductId) {
if (msg->wParam == DBT_DEVICEARRIVAL) {
qDebug() << "Device arrived";
emit this->deviceArrived(portName, info.serialNumber());
}
} else {
if (msg->wParam == DBT_DEVICEREMOVECOMPLETE) {
qDebug() << "Device removed";
emit this->deviceRemoved(portName);
}
}
}
}

return false;
}

**MainWindow.cpp**:

MainWindow::MainWindow(QWidget* parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
/* create the port */
this->port = new QSerialPort;
connect(this->port, &QSerialPort::readyRead, [&](){
QString receivedData = QString(this->port->readAll());
QStringList lines = receivedData.split("\r\n", Qt::SkipEmptyParts);

foreach (auto line, lines) {
ui->console->append(line);
qDebug() << line;
}
});
/* install the device filter */
this->filter = new SerialPortDeviceEventFilter(this);
connect(
this->filter,
&SerialPortDeviceEventFilter::deviceArrived,
[&](const QString& portName, const QString& serialNumber) {
if (this->port->isOpen()) {
return;
}

/* connect to the port */
this->port->setPortName(portName);
this->port->setBaudRate(115200);
this->port->setParity(QSerialPort::NoParity);
this->port->setFlowControl(QSerialPort::NoFlowControl);
bool open = this->port->open(QIODevice::ReadWrite);

if (! open) {
qDebug() << "error opening port";
}
});
connect(
this->filter,
&SerialPortDeviceEventFilter::deviceRemoved,
[&](const QString& portName) {
qDebug() << "See ya!";
/* disconnect from the port */
if (! this->port) {
return;
}

if (this->port->isOpen())

Читать полностью…

Qt - Reddit

Requesting to share beginners to intermediate level QT(C++) Projects

Hello Community!

I'm on the way to learn QT and have been following tutorials and docs for it. I've some experience working with web. What I've experienced while learning QT is that there is very much less resources available to learn Desktop app development with QT as compared to learning anything in web.

There is abundant of resources for learning web technologies. Video materials, blogs, Project walkthroughs and what not.

I'm facing difficulties in learning QT because of all these. I was thinking to learn it quickly by seeing the project that've already build. But I'm not being able to get to the correct resource or there is not much of those things really, I'm not sure.

Please share your opinions about the difficulty I'm facing and if there is a collection of better materials to learn QT (C++), please share those as well.

https://redd.it/1ez8mh5
@qt_reddit

Читать полностью…

Qt - Reddit

How high is chance of getting into Embedded Software Dev.

I'm a CS undergraduate and I want to get into Embedded Software development. Someone said, it's getting harder to get into ES development because of not having a CE degree. Is it true though?

I actually don't have any deep understanding about the electronics. But I do have good software development skills and expanding.

No motivational opinion please, just how you got into ES development as a CS graduate or a self-taught. Because things are changing, it's getting hard to just be doing what you like.

https://redd.it/1f9bd4t
@qt_reddit

Читать полностью…

Qt - Reddit

Event loop and multi-threading

Hello everyone,

# First, the context:

I currently write a dll in which I have to implement a method using Qt5, which is responsible for creating a TCP and UDP server.

mThread = new QThread();
mProxy = new Proxy();
mProxy->moveToThread(mThread);
mThread->start();
QObject::connect(mThread, &QThread::started, mProxy, &Proxy::init);

In the init method, call after the thread is started, there is the creation of the TCP and UDP server :

mTcpServer = new QTcpServer(this); 
mTcpServer->listen(QHostAddress::Any, TCPPROXYPORT)) 
mUdpServer = new QUdpSocket(this); 
mUdpServer->bind(QHostAddress::Any, UDPPROXYPORT)) 
connect(mUdpServer, &QUdpSocket::readyRead, this, &Proxy::onNewUdpConnectionFromUDP); // PROBLEM HERE
connect(TcpServer, &QTcpServer::newConnection, this, &Proxy::onNewConnectionFromTCP); // PROBLEM HERE

I've deliberately simplified the code here to leave only the essentials, but it's obvious that I'm running a whole battery of tests to check whether each element is working.

# The problem is:

When I call my dll's method from a basic simulator I've created, I properly receive the connection from UDP and TCP. So far, so good, you might say. But when I call the dll's method from the application I'm writing the dll for, the init method signals don't seem to be called, even though the servers are up and running (I can connect to them without any problem).

Since QThread::started was triggered, I don't think it's an event loop problem with the main application. I can even manually transmit the QTcpServer::newConnection signal and fall into the Proxy::onNewConnectionFromTCP method, but the signal is simply not sent when the server receives a connection, in the context of the main application of course.

# My request:

I obviously don't expect anyone to tell me the answer with so little context, but if you have any leads, I'd love to hear from you. I may not have mastered all the uses of event loops with Qt.

https://redd.it/1f7tnlz
@qt_reddit

Читать полностью…

Qt - Reddit

  color: App.Theme.lightNeutral
                        visible: sideBar.isExpanded
                        anchors.verticalCenter: parent.verticalCenter
                        anchors.left: crmIcon.right
                    }
                }
            }
            Rectangle {
                id: displayLine
                width: sideBar.width - 30
                height: 1
                color: App.Theme.accent
                anchors.left: parent.left
                anchors.top: crmDisplay.bottom
                anchors.leftMargin: 12
                anchors.topMargin: 10
            }
           

            Repeater {
                model: [
                    { icon: "qrc:/icons/contact_page_32dp_F0F5F9.png", text: "Contacts" },
                    { icon: "qrc:/icons/store_32dp_F0F5F9.png", text: "Companies" },
                    { icon: "qrc:/icons/confirmation_number_32dp_F0F5F9.png", text: "Tickets" },
                    { icon: "qrc:/icons/monitoring_32dp_F0F5F9.png", text: "Reports" }
                ]
                delegate: Rectangle {
                    id: sideBarItem
                    Layout.fillWidth: true
                    height: 40
                    color: "transparent"

                    Rectangle {
                        anchors.fill: parent
                        color: {
                            if (modelData.text === sideBar.selectedItem) {
                                return App.Theme.secondary
                            } else if (itemMouseArea.containsMouse && sideBar.isExpanded) {
                                return App.Theme.secondary
                            } else {
                                return "transparent"
                            }
                        }
                    }
                   
                    Item {
                        //spacing: 10
                        anchors.verticalCenter: parent.verticalCenter
                        anchors.left: parent.left
                        anchors.leftMargin: 10

                        Image {
                            id:sideBarItemIcon
                            source: modelData.icon
                            width: 24
                            height: 24
                            anchors.verticalCenter: parent.verticalCenter
                        }

                        Text {
                            id: iconText
                            text: modelData.text
                            color: App.Theme.lightNeutral
                            visible: sideBar.isExpanded
                            anchors.verticalCenter: parent.verticalCenter
                            anchors.left: sideBarItemIcon.right
                        }

                        Item {
                            Layout.fillWidth: true
                        }
                    }

                    Image {
                        id: chevronIcon
                        source: "qrc:/icons/chevron_right_32dp_F0F5F9.png"
                        width: 24
                        height: 24
                        anchors.right: parent.right
                        anchors.rightMargin: 10
                        anchors.verticalCenter: parent.verticalCenter
                        visible: itemMouseArea.containsMouse && sideBar.isExpanded
                    }

                    MouseArea {
                        id: itemMouseArea
                        anchors.fill: parent
                        hoverEnabled: true
                        onEntered: {
                            sideBar.isAnyItemHovered = true
                            hoverTimer.restart()
                        }
               

Читать полностью…

Qt - Reddit

QML Resource Packaging Issues

I'm developing a QML application using Pyside6 and am having issues with linking my main.py and main.qml file to other QML files. Here's the project repository: HubSpot-Clone

So I've had issues with packaging my Companies.qml Contacts.qml Reports.qml Tickets.qml files so that I can load them into the main window. I have even had issues with the Theme.qml file only able to get it to load using the command

import "." as Apps

QML has been working great for me accept for the packaging issues. Does anybody have any feedback?

Current directory is using a full directory path but I have also used "qrc:/main.qml" for the paths. I'm at a loss at this point.

Here's what I am currently trying using the q resource system in my main.qml code:

import QtQuick 2.15
import QtQuick.Window 2.15
import QtQuick.Layouts 2.15
import "qrc:/Theme.qml" as App

Window {
    width: Screen.width
    height: Screen.height
    color: App.Theme.primary
    visible: true
    title: qsTr("Demo")

    Rectangle {
        id: sideBar
        anchors.top: parent.top
        anchors.left: parent.left
        color: App.Theme.primary
        height: parent.height
        width: isExpanded ? 150 : 50

        property bool isExpanded: false
        property string selectedItem: ""
        property bool isSidebarHovered: false
        property bool isAnyItemHovered: false
       

        Behavior on width {
            NumberAnimation { duration: 200 }
        }

        Timer {
            id: hoverTimer
            interval: 50 // Short delay to prevent rapid toggling
            onTriggered: {
                sideBar.isExpanded = sideBar.isSidebarHovered || sideBar.isAnyItemHovered
            }
        }

         MouseArea {
            anchors.fill: parent
            hoverEnabled: true
            onEntered: {
                sideBar.isSidebarHovered = true
                hoverTimer.restart()
            }
            onExited: {
                sideBar.isSidebarHovered = false
                hoverTimer.restart()
            }
        }


        ColumnLayout {
            id: sideBarContent
            anchors.left: parent.left
            anchors.top: parent.top
            anchors.right: parent.right
            spacing: 10

            Rectangle {
                id: logo
                width: sideBar.width
                height: 50
                color: "transparent"
                Item{
                    //spacing: 10
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.left: parent.left
                    anchors.leftMargin: 10

                    Image {
                        source: "qrc:/icons/Hubspotlogo.png"
                        width: 24
                        height: 24
                    }
                }
            }
       
            Rectangle {
                id: crmDisplay
                width: sideBar.width - 10
                height: 40
                color: "transparent"

                Item {
                    //spacing: 10
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.left: parent.left
                    anchors.leftMargin: 10

                    Image {
                        id:crmIcon
                        source: "qrc:/icons/grid
view32dpF0F5F9.png"
                        width: 24
                        height: 24
                        anchors.verticalCenter: parent.verticalCenter
                    }

                    Text {
                        text: "CRM"
                     

Читать полностью…

Qt - Reddit

Seeking guidance on configuring cmake to use Qt6::Network

I want to make use of classes like QNetworkAccessManager, QNetworkReply, etc. to make a simple data fetching app from some api in Qt.
However, I'm unable to configure Cmake Properly because of which I'm getting an error as:
Process finished with exit code -1073741515 (0xC0000135)

My current cmake configuraiton is this:

cmakeminimumrequired(VERSION 3.29)
project(makingHTTPRequest)

set(CMAKECXXSTANDARD 20)
set(CMAKEAUTOMOC ON)
set(CMAKE
AUTORCC ON)
set(CMAKEAUTOUIC ON)


find
package(Qt6 COMPONENTS
Core
Gui
Widgets
REQUIRED)


addexecutable(makingHTTPRequest main.cpp
main.h)
target
linklibraries(makingHTTPRequest
Qt::Core
Qt::Gui
Qt::Widgets
Qt::Network
)

if (WIN32 AND NOT DEFINED CMAKE
TOOLCHAINFILE)
set(DEBUG
SUFFIX)
if (MSVC AND CMAKEBUILDTYPE MATCHES "Debug")
set(DEBUGSUFFIX "d")
endif ()
set(QT
INSTALLPATH "${CMAKEPREFIXPATH}")
if (NOT EXISTS "${QT
INSTALLPATH}/bin")
set(QT
INSTALLPATH "${QTINSTALLPATH}/..")
if (NOT EXISTS "${QT
INSTALLPATH}/bin")
set(QT
INSTALLPATH "${QTINSTALLPATH}/..")
endif ()
endif ()
if (EXISTS "${QT
INSTALLPATH}/plugins/platforms/qwindows${DEBUGSUFFIX}.dll")
addcustomcommand(TARGET ${PROJECTNAME} POSTBUILD
COMMAND ${CMAKECOMMAND} -E makedirectory
"$<TARGETFILEDIR:${PROJECTNAME}>/plugins/platforms/")
add
customcommand(TARGET ${PROJECTNAME} POSTBUILD
COMMAND ${CMAKE
COMMAND} -E copy
"${QTINSTALLPATH}/plugins/platforms/qwindows${DEBUGSUFFIX}.dll"
"$<TARGET
FILEDIR:${PROJECTNAME}>/plugins/platforms/")
endif ()
foreach (QTLIB Core Gui Widgets)
add
customcommand(TARGET ${PROJECTNAME} POSTBUILD
COMMAND ${CMAKE
COMMAND} -E copy
"${QTINSTALLPATH}/bin/Qt6${QTLIB}${DEBUGSUFFIX}.dll"
"$<TARGETFILEDIR:${PROJECTNAME}>")
endforeach (QT
LIB)
endif ()





https://redd.it/1f747c8
@qt_reddit

Читать полностью…

Qt - Reddit

How to use cmake FILE_SET with Qt?
https://forum.qt.io/topic/158493/how-to-use-cmake-file_set-option-with-qt

https://redd.it/1f61xbx
@qt_reddit

Читать полностью…

Qt - Reddit

I have made template project for frameless window that works on windows OS!
https://github.com/tongmon/qt-frameless-windows

https://redd.it/1f5v4yz
@qt_reddit

Читать полностью…

Qt - Reddit

Enable macOS "Wallpaper Tinting" for widgets?

For a while now, macOS has had an "Allow wallpaper tinting in windows" option which sort of tints the window color based on the wallpaper. It's a subtle effect, but noticeable when you compare a stark white QtWidgets window against a native mac application that can use the tinting.

I've asked around about a way to enable it in QtWidgets before, and for a while people were saying it wasn't possible unless you fake it one way or another. But recently ChatGPT gave me some code that seems to kind of work, but I don't blindly trust ChatGPT and I can't really find any documentation about this method that specifically says anything about window tinting. The code (Pyside6):

from PySide6.QtWidgets import QApplication, QMainWindow
from PySide6.QtCore import Qt
from PySide6.QtGui import QSurfaceFormat

# Set up the surface format for translucency
surfaceformat = QSurfaceFormat()
surface
format.setAlphaBufferSize(8)
QSurfaceFormat.setDefaultFormat(surfaceformat)

app = QApplication([])

# Create the main window
window = QMainWindow()

# Enable translucency
window.setAttribute(Qt.WA
TranslucentBackground)

# Show the window
window.show()

app.exec()

So basically it seems to be that you need to change the default QSurfaceFormat to one that has an 8-bit alpha channel? And add a Qt.WA_TranslucentBackground window flag? Can anyone explain this a bit better and confirm this is really doing what I want it to do?

https://redd.it/1f53xz8
@qt_reddit

Читать полностью…

Qt - Reddit

Any way to integrate Google Maps directions with QT?

Hi, I'm building a screen for my car and I'm doing the software in Qt (PySide6) in debían.

I want to integrate a gps system so you can put an address and the gps will give you the directions to go like Google Maps.

Is there any way to do this?

Maybe evening android auto inside or something?

Thanks!

https://redd.it/1f39x3k
@qt_reddit

Читать полностью…

Qt - Reddit

QRhi render issues under Windows D3D11

Hi, everyone. Recently I have been using QRHI of Qt 6 to do some image rendering tests on macOS and Windows 11. My goal is to render two graphics instances - a rectangle and a triangle, they have different model matrices, the model matrix is ​​bound to the vertex attributes through the buffer, the same code has different performance on the two platforms, macOS uses the Metal backend to perform as I expected, while Windows 11 uses the D3D11 backend, there are some problems, can you give some help to see what the problem is, the following is the main code snippet.

unsigned char* modelsData;

// The vertex coordinates and color attributes of the two graphics
float vertexData[] = {

//---- Position------ -----Color-----
// X Y Z R G B

// Rectangle Vertices Attributes
-100.0f, -100.0f, 0.0f, 1.0f, 0.0f, 0.0f,
100.0f, -100.0f, 0.0f, 1.0f, 0.0f, 0.0f,
100.0f, 100.0f, 0.0f, 1.0f, 0.0f, 0.0f,
100.0f, 100.0f, 0.0f, 1.0f, 0.0f, 0.0f,
-100.0f, 100.0f, 0.0f, 1.0f, 0.0f, 0.0f,
-100.0f, -100.0f, 0.0f, 1.0f, 0.0f, 0.0f,

// Triangle Vertices Attributes
-100.0f, -100.0f, 0.1f, 0.0f, 0.0f, 0.0f,
100.0f, -100.0f, 0.1f, 0.0f, 0.0f, 0.0f,
0.0f, 100.0f, 0.1f, 0.0f, 0.0f, 0.0f,
};

// SmileFaceRenderer is a QQuickRhiItemRenderer
SmileFaceRenderer::SmileFaceRenderer()
{
// instance count
m_instances = 2;
// model matrixes native buffer, each matrix
// has 64 byte size(4x4 float matrix)
modelsData= new unsigned char[64 * m_instances];
}

// Render initialize
void SmileFaceRenderer::initialize(QRhiCommandBuffer *cb)
{
if (m_rhi != rhi()) {
m_rhi = rhi();
...
...
}

if (!m_pipeline) {
m_pipeline = m_rhi->newGraphicsPipeline();
...
...
// create QRhi buffer for vertex data
m_vectexBuffer = m_rhi->newBuffer(QRhiBuffer::Immutable,
QRhiBuffer::VertexBuffer,
sizeof(vertexData)));
m_vectexBuffer->create();

// create QRhi buffer for model matrix data
m_modelBuffer = m_rhi->newBuffer(QRhiBuffer::Immutable,
QRhiBuffer::VertexBuffer,
64 * m_instances));
m_modelBuffer->create();

QRhiVertexInputLayout inputLayout;
inputLayout.setBindings({
// vertex position and color attribute data
{ 6 * sizeof(float), QRhiVertexInputBinding::PerVertex },
// model matrix data, PerInstance type, every vertices use
// the same model attribute in an instance drawing
{ 16 * sizeof(float), QRhiVertexInputBinding::PerInstance },
});

inputLayout.setAttributes({
// binding0, location0 is position, location1 is color
{ 0, 0, QRhiVertexInputAttribute::Float3, 0 },
{ 0, 1, QRhiVertexInputAttribute::Float3, 3 * sizeof(float) },
// binding1, separate a model matrix to 4 coloumn vec4,
// location2 to location5 represent the 4 vec4s
{ 1, 2, QRhiVertexInputAttribute::Float4, 0 },
{ 1, 3, QRhiVertexInputAttribute::Float4, 4 * sizeof(float) },
{ 1, 4, QRhiVertexInputAttribute::Float4, 8 * sizeof(float) },
{ 1, 5, QRhiVertexInputAttribute::Float4, 12 * sizeof(float) },
});

m_pipeline->setVertexInputLayout(inputLayout);
...
...

// upload data to target buffer
QRhiResourceUpdateBatch *batch = m_rhi->nextResourceUpdateBatch();
batch->uploadStaticBuffer(m_vectexBuffer.get(), vertexData);
batch->uploadStaticBuffer(m_modelBuffer.get(), modelsData);

Читать полностью…

Qt - Reddit

QML module First version of Custom Native WebView

Hello fellow Qt developers!

While developing r/mollohq , we found ourselves needing a lightweight WebView solution that wouldn't involve bundling QtWebEngine and a full Chromium.
We couldn't find an existing simple solution so we created QmlNativeWebView. Until Qt fixes QtWebView so it uses only os-bundled web engines, this will do :)

Features:
Avoid QtWebEngine bundling just to show web content
Works with Windows (WebView2 Edge) and macOS (WebKit)
Seamless integration with Qt/QML applications
Requires Qt 6.7+ (uses the new WindowContainer)

Why?
If you need web content in your Qt app but don't want the overhead of QtWebEngine, this component is for you. It's already being used in production in Mollo.

Current Status:
Windows and macOS support
No Linux support yet (contributions welcome!)

MIT licensed

Check it out and let me know what you think! Feedback, issues, and pull requests are all welcome.
https://github.com/mollohq/QmlNativeWebView

Happy coding!

https://redd.it/1f2cydt
@qt_reddit

Читать полностью…

Qt - Reddit

GradientText for Qt6

I cant figure out, how to make a gradient text for Qt6. Because QtGraphicsEffects was removed from Qt6

https://redd.it/1f11usl
@qt_reddit

Читать полностью…

Qt - Reddit

{
this->port->close();
}
});
qApp->installNativeEventFilter(this->filter);
}



https://redd.it/1f033bq
@qt_reddit

Читать полностью…

Qt - Reddit

Trying to download the community version online installer for linux

Hello, I'm new to Qt framework, I downloaded it 2 days ago and it was working fine, I just set up a new VM to use as development environment but I can't download anymore, I am here (https://www.qt.io/download-qt-installer-oss), I can pick windows or Mac but can't pick linux, am I missing the right link or something is broken in the website?

https://redd.it/1f00iir
@qt_reddit

Читать полностью…

Qt - Reddit

Install Qt6.5+ on Ubuntu 24.04

Hi all,

I haven't used Qt for several years. But now there is a tool I'd like to install on my machine that requires Qt6.5+ (https://github.com/emericg/toolBLEx) and I am totally confused. Qt 6.5 has been released a while ago now, but the default ubuntu apt installation seems to be 6.4.

When I try to download qt online installer, I am asked for my company details, saying it is available for a 10 day trial. But i don't want to develop anything, i just need the dependencies. Could anyone point me to the right direction?


Thanks

https://redd.it/1ez9c9w
@qt_reddit

Читать полностью…
Subscribe to a channel