Qt - Reddit
15 subscribers
302 photos
52 videos
4.3K links
News and discussion for the Qt Framework.

Subreddit: https://www.reddit.com/r/QtFramework

Powered by : @r_channels & @reddit2telegram
Download Telegram
Deploying Qt application on different platforms

Let's say that I created a Qt Widgets application on Windows. I need to deploy it for macOS and Linux as well. Is it necessary to build the the application again on other OSs? Will I have to install Qt on the other OSs and then rebuild for that OS? Is it not possible to do that while staying on Windows?

https://redd.it/18tt5nt
@qt_reddit
Why doesn't my QScrollArea scroll?

Qt newbe here.

I tried to create a QScrollArea and put some pushbuttons in it. Instead of scrolling the buttons Qt compresses them to fit the viewport no matter how may buttons I put there. The code is here. No one can explain what I'm doing wrong and how to fix it?

#include <QtCore>
#include <QtGui>
#include <QApplication>
#include <QScrollArea>
#include <QGridLAyout>
#include <QPushButton>

int main(int argc, char *argv[])
{
QApplication app(argc, argv);

QScrollArea scrollArea;
// scrollArea.setFixedSize(300, 400);

QWidget *widget = new QWidget();
scrollArea.setWidget(widget);
scrollArea.setWidgetResizable(true);
QGridLayout *layout = new QGridLayout;
scrollArea.setLayout(layout);

for(int n=0; n<17; n++) {
for(int m=0; m<3; m++) {
layout->addWidget(new QPushButton("Hubba Bubba"), n, m);
}
}

scrollArea.show();
return app.exec();
}

https://redd.it/18vzt6q
@qt_reddit
How to read PDFs in QtQuick? QtQuick.Pdf is not included in Qt 6?

When I try to import QtQuick.Pdf it says:
"qrc:/test/main.qml:3:1: module "QtQuick.Pdf" is not installed"

What can I do? Is it not on Qt 6 anymore?

https://redd.it/18tc21a
@qt_reddit
How to use video as a Texture

Hi

Basing on Qt's examples I managed to create an `Item` which allows to view 360⁰ equirectangular pictures.
I simply create `View3D` with properly setup `environment`:


environment: SceneEnvironment {
antialiasingMode: SceneEnvironment.MSAA
antialiasingQuality: SceneEnvironment.VeryHigh
lightProbe: Texture {
id: sourceTexture
}
backgroundMode: SceneEnvironment.SkyBox
}

and then I set `source` property of `sourceTexture` to url of an image.
Now I'd like to experiment with 360⁰ videos but I'm not sure how to do it.
My idea was to use `Texture`'s sourceItem which would be set to an item used as video sink of `MediaPlayer` but I'm not sure how exactly do it.




https://redd.it/18w30xo
@qt_reddit
How to mark bars in a specific range?
https://redd.it/18w2rc9
@qt_reddit
Driver not loaded error on my application

Hello,

I have created an application using Qt framework, which is using QMYSQL as database. While I am in the release build, the application runs well, but the thing is when I am running the .exe one alone (I used windeployqt.exe to get all of the necessary files for it to run properly), I am getting QSqlDatabase: QMYSQL driver not loaded. QSqlDatabase: available drivers: QSQLITE QODBC QPSQL. The thing is that I have all of the DLLs for mysql in the same folder as the application. I used mingw_64 as compiler.


https://redd.it/18t3u6j
@qt_reddit
Setting TextField text with model data outside delegate

&#x200B;

https://preview.redd.it/mpntzunv639c1.png?width=199&format=png&auto=webp&s=f8b2d135aec6dc4b609ef10c38e900509d05cefc

I have a QML UI element where I want to the user to be able to select an item from a combo box (connected to a subclassed QAbstractListModel) and have a series of TextFields and ComboBox populate with data from that item in the model. The user should be edit the data via the fields and update the entry in the model by pressing the "Update" button.

&#x200B;

I've come up with 2 potential methods so far:

&#x200B;

1. Using onCurrentIndexChanged(), set the text for each TextField by calling data(currentIndex, "RoleToDisplay"). When "Update" is pressed, either call setData() for each role we want to update, or implement a setPlanetData() method in my class which takes all the TextField's data as parameters and is responsible for calling dataChanged()
2. Have my Planet objects subclass from Q_OBJECT and expose the data via properties. However, I would think this would require me to have a binding of text: getPlanet(currentIndex).Gravity. This may prevent the user from modifying the values in the TextField as what ever is entered will be overwritten by the binding.

It's important to note that there will be a read-only instance of the above elsewhere in the application. In which case, any changes made via the form need to be reflected in the other display. Using the first method I suggested, that would probably require connecting to onDataChanged() and then repopulating the fields. It would be nice if there was a more automatic or declarative way to do this.

&#x200B;

Open to any other ideas/suggestions. Thanks!

https://redd.it/18t2iz9
@qt_reddit
A couple of QT beginner questions, do I need to differentiate between QT for Python and PyQT?

Hi guys, relatively new to Python, and been sitting on the sidelines really with GUI development for python, some of the frameworks looked a little well not very modern, I have made something basic in Tkinter before. QT for python looks really cool after watching a freecodecamp course I'm pretty excited about the possibilites. QT for Python and PyQT seem to be fairly intermingled, I kind of like Qt for pythons licensing better, but how do I avoid getting the frameworks mixed up?

Also I dont seem to be able to find much in the way of tutorials on how to inter mingle python code with QT to make a personalised app, maybe I'm looking at it from the wrong angle?

&#x200B;

Appreciate any help ;)

&#x200B;

Brett

https://redd.it/18sry51
@qt_reddit
Border around GridLayout (QML)

I have a GridLayout containing several Labels and TextFields. I want to put a border around the grid with equal spacing around the edges so I've placed the grid inside a Rectangle and set the border I want. The problem is, by setting the grid's anchors to fill the parent, we end up with a gap at the top and the bottom. I can get by this by scaling the owning Rectangle to the grid's minimum size, but this has some undesired effects:


Rectangle {
Layout.preferredHeight: grid22.height
Layout.preferredWidth: 200
color: "transparent"
border.width: 1
border.color: "#3d3d3d"
radius: 5

GridLayout {
id: grid22
anchors.top: parent.top
anchors.margins: 15
columns: 2
rowSpacing: 15

Is there another way to set the Rectangle's size to match the grid's size, or perhaps a way to remove the spacing at the top and bottom?

https://redd.it/18sfqet
@qt_reddit
Why is the QT open source-> commercial license rules so strange?

What end user will want to, or even know how to replace the QT libraries? It seems weird to me that this is a requirement to use QT free license for a commercial app.

https://redd.it/18wysnc
@qt_reddit
QT UI Design Responsive without empty when we change the display resolution

Not able to auto adjust screen on different size screen resolution . Is there any way to achieve the responsive UI contents ??

Right side and bottom side space is keep on increasing when we change the resolution but UI have to resize and fit it into different screen resolution

https://redd.it/18y4igs
@qt_reddit
how to compile an old qt4 project with GitHub actions using windows?

I'm extremely sorry if the question sounds dumb, but i really need help with this and there is no answer online about that i can find, i've barely managed to compile my project on ubuntu

https://redd.it/1acxxv8
@qt_reddit
Google API in QML

How do I integrate Google map api into QML, I am having hard time getting the api key to give out the map inside my rectangle. It doesn't even show up. There will be different errors when I try diffferent methods. Can somebody help with this.
My intention is to simply, show the google map inside a rectangle with my current location and nothing more.

https://redd.it/1ac6e3t
@qt_reddit
Qt Creator "can't find any valid Kit".. except, there is a kit?

I was just about to get started with my first project on Qt Creator when I got the error stated in the title.

I installed Qt Creator 12.0.1 from the online installer/open source installer. I'm on Qt 6.6.1, PySide6 and Windows 11. I created the project using the Qt Quick project with Python option.

I checked and there is actually a kit getting auto detected. The correct version of Qt is also selected.

I honestly don't know what to do anymore. I uninstalled and reinstalled Qt Creator but that didn't do it either. I can provide screenshots and more information if needed.

https://redd.it/1abfsq6
@qt_reddit
Using custom fonts

Is it possible to change the QLabel font using the style sheet, but without installing the font on the computer, but using Res.qrc? C++/CMake

https://redd.it/19ern53
@qt_reddit
How to set value to model property in Qt Quick QComboBox in C++ during run-time from HTTP response

I want to populate the list of Dropdown box (QComboBox) from the Http response during run-time. Most of the internet resources suggests to use setInitialProperties() method in main() method.

This is my attempt: I have created my own model by sub-classing QAbstractListModel and I believe I've implemented all the required methods correctly. And then I set the model to the QComboBox QObject using setProperty() method.


class DataObject
{
private:
QString mtext, mvalue;
public:
DataObject(QString text, QString value);
const QString& getText() const;
const QString& getValue() const;
};

&#x200B;

class DataObjectModel : public QAbstractListModel
{
QOBJECT
public:
explicit DataObjectModel(QObject *parent = nullptr);
// Basic functionality:
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
QHash<int, QByteArray> roleNames() const;
enum DataObjectRoles {
TextRole = Qt::UserRole + 1,
ValueRole
};
Q
INVOKABLE void push(const QString &text, const QString &value);
QINVOKABLE void print();
private:
QList<DataObject> m
dataObjects;
};


During run-time, a slot is invoked after Http response is received and data is parsed and added to User-defined model. Then I'm trying to set that user-defined model to QComboBox like this :


DataObjectModel model;
foreach(...){
...
model.push(text,value);
}
QObject snapshotsDropdown = screen01RootQObject->findChild<QObject>("snapshotDropdown",Qt::FindChildrenRecursively);
if(snapshotsDropdown != nullptr){
snapshotsDropdown->setProperty("model", QVariant::fromValue(&model));
}

Problem : But the QComboBox shows empty list to select from. The drop-down list is not updated.

https://redd.it/19eo49s
@qt_reddit
Looking at CMakeLists for BasicDrawing Example

Folks:

I see the followinig in the CMakeLists.txt for the BasicDrawing Example:



settargetproperties(basicdrawing PROPERTIES WIN32EXECUTABLE TRUE MACOSXBUNDLE TRUE )

Does this mean that I cannot use this example on Linux?

Thank You
Mark Allyn

https://redd.it/19enbxa
@qt_reddit