News and discussion for the Qt Framework. Subreddit: https://www.reddit.com/r/QtFramework Powered by : @r_channels & @reddit2telegram
QML perspective transforms
Is there any way to apply perspective transforms(like you can with CSS) in QML without actually using the 3d module? If not, is it possible to request that feature?
https://redd.it/1l4bgx1
@qt_reddit
Is it even possible to create a single small size executable installer?
Qt C++ Widgets(QDialog only), Linux.
Like Google provides for Chrome. We click on it and then it downloads the whole application binaries onto the client system.
I think it should be no more than \~5 MiB otherwise there is no point of this type of downloader.
Yeah I understand at least these libs would need to be linked statically:
libQt6Widgets
libQt6Core
libstdc++
libgcc_s
libQt6Gui
libQt6DBus
libQtNetwork
libssl
libcrypto
Sounds like impossible to me even within 10 MiB and this is after stripping all the symbols / minimum release build.
It takes like 2-3 hours to build Qt from source on my system but that's not the problem in the end. What do you say? Has anybody ever tried something like that? Should I even bother?
P.S.: LGPL rules shall be followed.
https://redd.it/1l3nawj
@qt_reddit
How to change installer language?
I'm trying to install QT, but the installer is in Japanese and I can't understand it. How do I change the language to English?
https://preview.redd.it/rxxtes0zrs4f1.png?width=1058&format=png&auto=webp&s=f66b5347df5eaa7a22a31017568fb81540e64946
https://redd.it/1l2qvjc
@qt_reddit
Search KDE source code across most KDE projects tutorial
https://www.youtube.com/watch?v=qe6JU4ujSKM
https://redd.it/1l1m9t7
@qt_reddit
custom titlebar
how do i make my own custom titlebar? I dont like the regular windows 11 titlebar and i wanted to make my own
Like this
https://preview.redd.it/0kpy9ht5zc4f1.png?width=279&format=png&auto=webp&s=134e3dc944f79119592593a6fd2f61c656fbe8a9
https://redd.it/1l0vypl
@qt_reddit
QTableView dragging - two positions between row items?
I'm trying to get drag/drop working to move rows within a QTableView and I'm so close except one annoying issue.
My class (DragTableView) is a child of QTableView and uses the following code to get the drop row:
void DragTableView::dropEvent(QDropEvent* event)
{
auto destinationRow = indexAt(event->position().toPoint()).row();
}
The problem is that when the mouse is between two row items, the function can return one of two indexes.
On the GUI this can be seen as the highlighted line (which is on the separator between rows) being slightly higher or slightly lower depending on the precise precision of the mouse. Each position returns a different row.
Is there any way to change this behaviour to either return a consistent index or identify the situation (i.e. whether the '1 pixel higher' line is selected or the '1 pixel lower' line is selected so I can compensate?
Thanks.
https://redd.it/1l08aeo
@qt_reddit
Setting up certs & profiles Qt for iOS and Mac
Is there a really good write-up anywhere on how to get the MyApp.pro file set up for code signing? I have a big project that was created by others that I'm trying to jump into. We have it working for our release builds, but as an individual developer on my personal Mac I'm not quite mastering it.
I have certs, ids, devices, and profiles set up on developer.apple.com
The Code Sign Identity that I'm using is the SHA-1 that I see when I right click on my Development Cert, then right click and choose Get Info. But I get " Could not find appropriate signing identity for " sorts of errors when it goes to sign the .pkg.
But that's just an example. I've gotta master all the details quickly. Any good HowTos tutorials or (even) official docs that I should read first?
QMAKE_XCODE_CODE_SIGN_IDENTITY = "8xxxxxx"
QMAKE_PROVISIONING_PROFILE = "9xxxxxxx"
MY_ENTITLEMENTS.name = CODE_SIGN_ENTITLEMENTS
MY_ENTITLEMENTS.value = ../../appxxxxx.entitlements
QMAKE_MAC_XCODE_SETTINGS += MY_ENTITLEMENTS
Issue with calling a DBus method
Hi all!
I'm trying to call a DBus method with the following signature:
AddConnection (Dict of {String, Dict of {String, Variant}} connection) ↦ (Object Path path)
{
"connection": {
"id": GLib.Variant('s', "TestGSM"),
"type": GLib.Variant('s', "gsm")
},
"gsm": {
"apn": GLib.Variant('s', "internet")
}
}
Type of message, “(a{sv})”, does not match expected type “(a{sa{sv}})”
QVariantMap
as the parameter. However, I am sending nested QVariantMap
s.QDBusInterface connectionSettingsInterface(
NM_DBUS_SERVICE,
NM_DBUS_PATH_SETTINGS,
NM_DBUS_INTERFACE_SETTINGS,
QDBusConnection::systemBus());
QVariantMap gsmSettings = {
{ "apn", "internet" }
};
QVariantMap connectionSettings = {
{ "id", "TestGSM" },
{ "type", "gsm" }
};
QVariantMap settings = {
{ "gsm", gsmSettings },
{ "connection", connectionSettings }
};
QDBusReply<void> result = connectionSettingsInterface.call("AddConnection", QVariant::fromValue(settings));
QVariant
. It happens regardless of me passing settings
directly or explicitely wrapping it in a QVariant
like in the posted code. qdbus_cast
, and I tried using QDBusArgument
instead, but whichever combination I try it fails in the same way.Meet Kourier, the fastest, lightest, and 100% HTTP syntax-compliant open-source server.
https://github.com/kourier-server/kourier
https://redd.it/1kvunvf
@qt_reddit
QT Compression
Has anyone figured out how to compress your .exe for QT6 when you've upgraded to windows 11? I had no problems with compressing prior to my upgrade to windows 11 and now, I can't find anything that works. If anybody knows of anything it would be greatly appreciated.
https://redd.it/1kvl9ru
@qt_reddit
Composition vs Aggregation when working with models
Consider this fictional scenario:
We want to develop a university management system and need to make use of Qt's model architecture. The basic data structure is as follows. A University has multiple Courses. A Course has multiple Modules.
We have 3 list views, for University, Course, and Module. Selecting a University, should display the respective Courses in the Course list, and selecting a Course should display the respective Modules in the Module list. In future, we may wish to add additional views and/or present our data differently, so our model design should be flexible.
In any case, I think it makes sense to have 3 models, subclassed from QAbstractListModel, UniversityModel, CourseModel, and ModuleModel.
Now to main the question. In a non-GUI application, I would simply have a University class that has a vector of Course, which in turn has a vector of Module. If I were to apply this composition approach in this scenario, I would re-populate the Course and Module models as items are selected, and delegate object ownership and inter-model communication to a manager class.
With only 3 list views, I imagine this approach would work just fine, while allowing us to respect the "has-a" relationship of our data. However, should we wish to use our models in additional views (with potentially different selections), we would most likely need to introduce additional models. Effectively, you would have a model for every view.
The alternative (aggregation?) I think would be to flatten our data across the 3 models, such that University contains all Universities, Course contains all Courses, and Module contains all Modules. The Course class would have a University ID var, and the Module class would have a Course ID var, which we would use to associate with our parent/children. Additionally, we would have 3 sort/filter proxy models which we would use to filter specific views.
So, which of the two approaches plays best with Qt's model architecture?
https://redd.it/1kuzaob
@qt_reddit
How to install QGraphs on Ubuntu 24.04??
QT 6:
Seems that QGraphs has some functionality I need (draggable points for QLineSeries) that isn't in QCharts.
I can't seem to figure out how to install QT6Graphs. Worse, Google results will completely conflate graphs/charts, and show me info for charts instead.
https://redd.it/1kuqzk3
@qt_reddit
Struggling to pass around a QChartView in a PySIde6 + Qml Application.
Hi !
For an application I’m working on, I need to work on a Qml graph (create and remove series, make it scroll, render points on screen from numpy arrays…), ideally inside of a Python module using the PySide6 library. This is supposed to be easy to adjust by non programmers, so writing code in the frontend (outside of python bindings using the `Bridge` pattern shown in [this tutorial](https://doc.qt.io/qtforpython-6/tutorials/qmlintegration/qmlintegration.html)) is discouraged, as my module should do most of the work by it self.
While I seem to be able to seamlessly pass a `QLineSeries` object from my Qml frontend to my Python Backend using a slot, I can’t do that with the `QChartView` element, I get an `Unknown method parameter type: QChartView*` error. This sucks since `QLineSeries` doesn’t give me enough control (can’t manage series in my graph, for instance).
I tried to use `QChartView`’s parent class (`QChart`) in the slot parameter but got the same error (just with `QChart` instead of `QChartView`).
I then tried using a simple `QObject` in the parameter, but even though the methods for `QChartView` were recognised (i.e. calling them wouldn’t instantly throw an error), they seem to always return `None`.
I looked into casting my object back into a `QChartView`, but there doesn’t seem to be a python equivalent to c++’s `qobject_cast`, and while I did find the [`QMetaObject.cast`](https://doc.qt.io/qtforpython-6/PySide6/QtCore/QMetaObject.html#PySide6.QtCore.QMetaObject.cast) method, it always throws an error when I try to use it, so I have no idea what it’s actually used for.
I then tried to create a new type of chart by inheriting from `QChartView` and register it as a qml element, but I never was able to have anything render on screen, and trying to put *anything* inside it Qml (like giving it a height and width) would throw an error.
I feel like i thied everything I could but nothing seems to ever work. If you guys have an idea on how to accomplish this, that would be very nice. Here is a code example that illustrates the probems I had (both files should be in the same folder) :
- main.py :
```
#!/usr/bin/env python3
import sys
from os.path import abspath, dirname, join
import random
import numpy as np
from PySide6.QtCore import QObject, Slot, QPoint
from PySide6.QtQml import QQmlApplicationEngine, QmlElement
from PySide6.QtCharts import QChartView, QChart, QLineSeries
from PySide6.QtWidgets import QApplication # <---
# To be used on the @QmlElement decorator
# (QML_IMPORT_MINOR_VERSION is optional)
QML_IMPORT_NAME = "io.qt.textproperties"
QML_IMPORT_MAJOR_VERSION = 1
@QmlElement
class Bridge(QObject):
def __init__(self, parent=None):
super(Bridge, self).__init__(parent)
@Slot(QLineSeries)
def update_series(self, series):
series.replace([QPoint(i, random.uniform(0, 100)) for i in range(200)])
@Slot(QChartView)
def update_chart(self, chart):
chart.series(0).replace([QPoint(i, random.uniform(0, 100)) for i in range(200)])
@Slot(QObject)
def update_object(self, chart):
chart.series(0).replace([QPoint(i, random.uniform(0, 100)) for i in range(200)])
@QmlElement
class PyChart(QChartView):
def __init__(self, parent=None):
super(PyChart, self).__init__(parent)
if __name__ == "__main__":
app = QApplication(sys.argv)
engine = QQmlApplicationEngine()
qmlFile = join(dirname(__file__), 'main.qml')
dir_path = sys.path[0]
engine.addImportPath(dir_path)
engine.load(abspath(qmlFile))
if not engine.rootObjects():
sys.exit(-1)
sys.exit(app.exec())
```
- main.qml
```
import QtQuick 2.10
import QtQuick.Layouts 1.11
import QtQuick.Window 2.5
import QtQuick.Controls 2.4
import QtCharts 2.0
Window {
id: window
title: qsTr("QML and Python graphing dynamically")
width: 640
height: 480
visible: true
Bridge { id: bridge }
ColumnLayout {
anchors.centerIn: parent
RowLayout {
QTimer causing ghost windows to open (in .exe format)
Hey all, when I export my app into an exe using pyinstaller —onefile —windowed, everything looks and works fine, until the QTimers kick in.
I have set them up to check if there’s a VPN connection, but every 10 seconds when the timer checks for VPN, it opens a window.
vpn_timer.timeout.connect(update_vpn)
vpn_timer.start(10000)
The window looks like a terminal but it opens and closes so fast that it doesn’t even load a colour. It does take over the screen, so I have to keep clicking the app when it does happen. I noticed it also happens when I run the app for the first time, and one instantly opens and closes.
I can share more things if required, just wanted to see if there’s anything known on how to resolve.
https://redd.it/1krpp84
@qt_reddit
QtWidgets To QML Migration (PySide6)
Hi, I have a QtWidgets-based application with a Python/PySide6 backend. I am trying to convert all of my UI to QML.
My strategy is to incrementally convert smaller UI components using QQuickWidget to embed the QML files, then tackle the larger interfaces. Is there a way I can incorporate tools like Qt Design Studio or Qt Creator to design the UI components via QML?
I may not be asking the right question, but I mainly want to know how the workflow is like for you guys for working with QML.
https://redd.it/1l3rxo7
@qt_reddit
qtedit4 - v0.0.10
This month I added sponsorship options, as well as a YouTube playlist in which I demo the IDE by fixing bugs, and developing features using the IDE itself. See https://www.youtube.com/playlist?list=PLQeAIMKe60pMtZp3KZTmYoYXySy6UlvD3
The LSP integration is slowly maturing. I am testing a new library for LSP support, see repo https://github.com/diegoiast/lsp-client-demo-qt . Code from that demo/experiment will move to the IDE when its ready. The split view is more stable, project manager is getting more usable.
https://github.com/diegoiast/qtedit4/releases/tag/v0.0.10
https://redd.it/1l3fk16
@qt_reddit
Difference between Qt Designer, Qt Design Studio and Qt Creator
Guys I wanna develop an app using PyQt, and I'm using qt designer as it helps to visualise stuff live. I watched a lot of tutorials on it as well, can someone differentiate between all of these, I don't know if qt design studio or qt creator is better or than qt designer or is for me. Help me pls
https://redd.it/1l2b3bm
@qt_reddit
Qt 6.10 will get support for qml flexbox layouting
https://doc-snapshots.qt.io/qt6-dev/qml-qtquick-layouts-flexboxlayout.html
https://redd.it/1l1d05m
@qt_reddit
Does anyone have Qt Widgets (not QML) mobile apps in production?
E.g. using some third-party Materials styles for widgets or similar. What's your experience?
https://redd.it/1l0u9fg
@qt_reddit
Qt Creator Build Failing - "Cannot find .pro file" & Android NDK Error (I'm a beginner, please help )
https://redd.it/1l00gr7
@qt_reddit
Creating a custom QtQuick ListView?
I am currently using the qml ListView to display custom rendered delegates. The more I am using the built-in ListView, the more i keep running into problems with e.g. zoom, touch, scrollspeeds, resizing, etc.
I was thinking about creating a custom ListView that handles all of this in c++ instead of doing it in javascript from qml.
I do not have a lot of experience in subclassing QQuickItem to create custom Qml objects though and am wondering if this is reasonable to do, how much work this would be and if there might already be better solutions to this.
I'd appreciate any input on this.
https://redd.it/1kz0def
@qt_reddit
Kourier: the fastest server for building web services is open source and written in C++/Qt
https://github.com/kourier-server/kourier
https://redd.it/1kxfy5z
@qt_reddit
Qt Designer is mandatory to use Qt Framework with C++?
A few days I try to start to use Qt Framework with C++ but when I try to download just the framework the website always require me sing up and this just give me 10 days for trial but when It finished what happen?. I mean, can I just download and install the Qt framework on windows to use a different IDE, maybe Vscode, or vim on Linux? 🙏🏼 Thanks a lot.
https://redd.it/1kw7yid
@qt_reddit
Using OPC and PyQt5 to display values
I'm developing an application in PyQt5 with the aim of reading values from an OPC UA server and displaying them in real time. For now, I'm just testing the asyncua library with a simple example, before integrating the logic into the main application.
The problem I'm facing is this: When I run the code, it only reads the initial value from the OPC node. I'm monitoring the variables with UAExpert and confirm that the values are being updated correctly on the server. However, during the execution of my program, these values are not updated on the display.
Has anyone experienced something similar or know what might be missing for the real-time updates to work correctly?
Thanks in advance for any help!
The code:
class SubHandler:
def init(self, updatecallback):
self.updatecallback = updatecallback
def datachangenotification(self, node, val, data):
logger.info(f"Data change on {node}: {val}")
self.updatecallback(node.nodeid.tostring(), val)
class OPCWindow(QWidget):
def init(self, nodeids):
super().init()
self.setWindowTitle("OPC UA Async Monitor")
self.nodeids = nodeids
self.labels = {}
self.layout = QVBoxLayout()
for i, nodeid in enumerate(self.nodeids):
label = QLabel() #QLabel(f"Value {i+1}: Loading...")
self.labelsnode_id = label
self.layout.addWidget(label)
self.setLayout(self.layout)
def updatevalue(self, nodeid, value):
if nodeid in self.labels:
self.labels[nodeid].setText(f"{nodeid} : {value}")
async def main():
opcurl = "opc.tcp://192.168.1.100:4840"
nodeids = ["ns=7;s=Tag1", "ns=7;s=Tag2"]
app = QApplication(sys.argv)
loop = QEventLoop(app)
asyncio.seteventloop(loop)
window = OPCWindow(nodeids)
window.show()
async with Client(url=opcurl) as client:
for nodeid in nodeids:
try:
value = await client.getnode(nodeid).readvalue()
window.updatevalue(nodeid, value)
except Exception as e:
logger.error(f"Error reading {nodeid}: {e}")
window.updatevalue(nodeid, "Error")
handler = SubHandler(window.updatevalue)
subscription = await client.createsubscription(500, handler)
nodes = client.get_node(nid) for nid in node_ids
await subscription.subscribedatachange(nodes)
logger.info("Subscription created and running.")
with loop:
await loop.runforever()
if name == "main":
asyncio.run(main())
https://redd.it/1kvu7f1
@qt_reddit
QT app built in docker container results in "no version information available" when run on PC (Linux)
I can successfully build my app using cmake in a Docker container, but when I try to run the resulting binary on my normal machine, I get:
./build/dbmsgui: /lib/x8664-linux-gnu/libQt6Charts.so.6: no version information available (required by ./build/dbmsgui)
./build/dbmsgui: /lib/x8664-linux-gnu/libQt6Core.so.6: version `Qt6.9' not found (required by ./build/dbmsgui)
./build/dbmsgui: /lib/x8664-linux-gnu/libQt6SerialPort.so.6: no version information available (required by ./build/dbmsgui)
These files are installed. Both systems are Ubuntu 24.04. I'm building using a QT install that is installed via aqt
Googling for this doesn't come up with a lot of results.
If I build the app in the host machine, it runs as expected.
https://redd.it/1kvbu3k
@qt_reddit
Code crashing at doc.drawContents( &painter ); HELP needed to resolve !!
Result SummaryExporter::exportTo( DataDestination & destination )
{
QTemporaryFile tempFile;
if( !tempFile.open() )
return ResultQsl( "Cannot open temporary file for writing PDF" );
// Create PDF writer targeting the temp file
QPdfWriter pdfWriter( &tempFile );
pdfWriter.setPageSize( QPageSize::A4 );
pdfWriter.setResolution( 300 ); // dpi
// Create QTextDocument
QTextDocument doc;
doc.setPlainText( "Sample PDF File" );
// Paint the document manually using QPainter
QPainter painter( &pdfWriter );
if( !painter.isActive() )
{
return ResultQsl( "Painter failed to activate on QPdfWriter" );
}
doc.drawContents( &painter );
painter.end(); // End painting
// Read PDF data from temp file
tempFile.seek( 0 );
QByteArray pdfData = tempFile.readAll();
destination.writeData( pdfData, getDataType() );
return Result();
}
https://redd.it/1kuy2uo
@qt_reddit
Layout.fillWidth: true
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
Button {
text: "Update graph using Series"
onClicked: bridge.update_series(chart.series(0))
}
Button {
text: "Update graph using Chart"
onClicked: bridge.update_chart(chart)
}
Button {
text: "Update graph using QObject"
onClicked: bridge.update_object(chart)
}
}
ChartView {
id: chart
x: 180
y: 90
width: 500
height: 300
ValueAxis{
id: axisX
min: 0
max: 200
}
ValueAxis{
id: axisY
min: 0
max: 100
}
Component.onCompleted: {
chart.createSeries(ChartView.SeriesTypeLine,"Signal",axisX,axisY)
}
}
PyChart {
// width: 500
// height: 300
}
}
}
```
https://redd.it/1krvk1t
@qt_reddit
Utility for wayland cursor confining and locking within a Qt6 application
After banging my head for a while, I managed to get wayland pointer locking and confining working on a running Qt application.
Here's the repo with examples for anyone interested:
https://github.com/ien646/WaylandQtPointerConstraints-mirror
https://redd.it/1krwb2i
@qt_reddit
Test/Run Linux Build with WSL2
Hello. I'm using Qt 5/6 for some projects at work. I need to test some changes in Linux and decided to try WSL2. I got WSL setup and changed my terminal in QtCreator to point at the WSL terminal. How do I build/run the application for Linux? What would I need to change in the Kit?
Right now my company uses qmake and haven't switch to cmake yet. So I'm kind of stuck using QtCreator for my builds. I'm relatively new to Qt and Linux.
Thank you.
Edit: I'm trying to avoid redownloading Qt and cloning the repo in the WSL instance.
https://redd.it/1krf1ck
@qt_reddit