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
How to create a QOpenGLContext from a GLFW EGL window?

I wanted to embed a QML scene into a GLFW window using QQuickRenderControl. From what I can see, one of the first steps is to get the OpenGL context from GLFW, and this is where I run into an issue. My code crashes on the line: QOpenGLContext \*glfwQtContext = QNativeInterface::QEGLContext::fromNative(eglContext, eGLDisplay);. Am I doing something wrong? Configuration: Qt 6.9, Ubuntu 24.04 Wayland, GLFW 3.4.

#include <QGuiApplication>
#include <QCoreApplication>
#include <QOpenGLContext>
#include <QOffscreenSurface>

//#define GLFW_EXPOSE_NATIVE_WAYLAND
#define GLFW_EXPOSE_NATIVE_EGL

#include <GLFW/glfw3.h>
#include <GLFW/glfw3native.h>

#include <iostream>

int main(int argc, char *argv[])
{
//qputenv("QT_QPA_PLATFORM","eglfs");
qputenv("QT_QPA_PLATFORM","wayland");
QGuiApplication app(argc, argv);

if(!glfwInit()){
std::cerr << "Failed initialize glfw";
exit(1);
}

glfwWindowHint(GLFW_CONTEXT_CREATION_API, GLFW_NATIVE_CONTEXT_API);
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_ANY_PROFILE, GLFW_OPENGL_CORE_PROFILE);

GLFWwindow* window = glfwCreateWindow(800, 600, "Qml in GLFW window", nullptr, nullptr);
if(!window){
std::cout << "Wndow creation failed!";
exit(EXIT_FAILURE);
}else{
std::cout << "Sucessful window creation!" << std::endl;
}

glfwMakeContextCurrent(window);

EGLContext eglContext = glfwGetEGLContext(window);
EGLDisplay eGLDisplay = glfwGetEGLDisplay();
QOpenGLContext *glfwQtContext = QNativeInterface::QEGLContext::fromNative(eglContext, eGLDisplay);

glfwQtContext->create();

if(!glfwQtContext){
std::cout << "[ERROR] Failded to create QOpenGLContext from glfw context !!" << std::endl;
exit(EXIT_FAILURE);
}else{
std::cout << "[SUCCESS] Successfull create QOpenGLContext from glfw context !!" << std::endl;
}

return 0;
}

Additionally, I tried doing something similar with GLX, and it seems that the context is created successfully—the program doesn't crash, though I haven't tried rendering yet, as I am much more interested in the EGL version.

#include <QGuiApplication>
#include <QCoreApplication>
#include <QOpenGLContext>
#include <QOffscreenSurface>
#define GLFW_EXPOSE_NATIVE_GLX
#include <GLFW/glfw3.h>
#include <GLFW/glfw3native.h>
#include <iostream>

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


if(!glfwInit()){
std::cerr << "Failed initialize glfw";
exit(1);
}

glfwWindowHint(GLFW_CONTEXT_CREATION_API, GLFW_NATIVE_CONTEXT_API);
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_ANY_PROFILE, GLFW_OPENGL_CORE_PROFILE);

GLFWwindow* window = glfwCreateWindow(800, 600, "Qml in GLFW window", nullptr, nullptr);
if(!window){
std::cout << "Wndow creation failed!";
exit(EXIT_FAILURE);
}else{
std::cout << "Sucessful window creation!" << std::endl;
}

glfwMakeContextCurrent(window);

GLXContext glxContext = glfwGetGLXContext(window);
QOpenGLContext *glfwQtContext = QNativeInterface::QGLXContext::fromNative(glxContext);

glfwQtContext->create();

if(!glfwQtContext){
std::cout << "[ERROR] Failded to create QOpenGLContext from glfw context !!" << std::endl;
exit(EXIT_FAILURE);
}else{
std::cout << "[SUCCESS] Successfull create QOpenGLContext from glfw context !!" << std::endl;
}

QOffscreenSurface surface;
glfwQtContext->makeCurrent(&surface);

return 0;
}

https://redd.it/1u38baj
@qt_reddit
Projects With Great Plugin Architecture

Hello,

I have some decent experience with widgets but have been opening up to the idea of a large project with a qml front end and c++ handling most of the functionality.

One of the ideas I would like to explore while still deciding on the overall structure is plugin support, either giving users a python interface (similar to blender) or entirely in c++ using plugin interfaces.

Are there any projects that do either or both of these things well in your opinion? I would love to take a look and observe what’s been tried, if users like it (or if there are tons of issues entries for them lol), and what might work best for my target application.

I’m curious to see how these interfaces split up responsibilities, what needs to be done for qml (say if a user wants their plugin to have a menu/action), and how to interact with the application’s data manager (this in particular seems straightforward to me, so that must mean it’s probably not).

https://redd.it/1u3axlz
@qt_reddit
Making QT work in my docker container

Heyaa, im working on a small project. Which uses the Pygame library and utilizes QT to basically have a transparent background. Point is when I tried the project on my other laptop which is more higher end(Nvidia GPU there) I got AVX2 error. Tinkered around and didnt really got far, so I thought hey I have a "It works on my machine" moment so I thought how about I utilize docker. Im using the Pyside6 library for QT. From what I know its a cli program so no graphical passthrough so I thought oke how about I somehow passthrough the screen info which is all I really needed, but that is a GUI app so yeaah. As you see im quite the noob here. Maybe its more of a Docker problem? But since I am using QT I thought it would be nice asking here first.


in the Dockerfile I wrote this:
```Docker
FROM python:3.13-slim



WORKDIR /src



RUN apt-get update && \\

apt-get install -y -qq \\

libsdl2-dev \\

python3-xlib \\

libx11-dev \\

libxrandr-dev \\

libxkbcommon-x11-0 \\

libxcb-cursor0 \\

libxcb-xinerama0 \\

libxcb-icccm4 \\

libxcb-image0 \\

libxcb-keysyms1 \\

libxcb-randr0 \\

libxcb-render-util0 \\

libxcb-util1 \\

libxcb-xfixes0 \\

libxcb-shape0 \\

libfontconfig1 \\

&& rm -rf /var/lib/apt/lists/*



ENV QT_QPA_PLATFORM=xcb



COPY requirements.txt .



RUN python -m venv .venv && \\

.venv/bin/pip install --upgrade pip && \\

.venv/bin/pip install -r requirements.txt



COPY src .



CMD [".venv/bin/python", "main.py"\]

```

running this didnt really do it so I thought writing a docker compose might do the job?

```yml
services:

deskmate:

image: deskmate:latest

build:

context: src

dockerfile: Dockerfile

environment:

\- PYGAME_DETECT_AVX2=1

\- DISPLAY=${DISPLAY:-:0}

\- QT_QPA_PLATFORM=xcb

\- QT_X11_NO_MITSHM=1

\- QT_DEBUG_PLUGINS=1

\- XDG_RUNTIME_DIR=/tmp/runtime-root

volumes:

\- /tmp/.X11-unix:/tmp/.X11-unix:rw

cap_add:

\- SYS_ADMIN

devices:

\- /dev/dri:/dev/dri

```


Im on OpenSUSE Tumbleweed where I work on this but the python container utilizes debian as you might see

https://redd.it/1u3lp06
@qt_reddit
Why is it not removing the appropriate time from the list

i am using PyQt and I have a list that sorts the time according to the 24 hour time

I do not know why it stops removing at a certain point. I believe it has to do with my remove_time(self) method but I am unsure

can someone give me advice based on this issue on what I can do

I have attached the source code link so you can get an idea of what the code looks like

source code

Honestly I am aware the code looks sloppy but I am just going with it.

Look at problem here

https://redd.it/1u7vmi5
@qt_reddit
Zenkai: a fast and customizable app launcher written in Zig + Qt
/r/Zig/comments/1u838md/zenkai_a_fast_and_customizable_app_launcher/

https://redd.it/1u84s75
@qt_reddit
Two years

Hello!

For the past two years, I've been interested in Linux desktop environments and desktop shell development. I really enjoyed experimenting with Hyprland, customizing my setup, exploring source code, writing small plugins, and learning how everything works under the hood.

Then QuickShell came along. Since it seemed to be used in almost every modern desktop setup I saw, I initially thought that Material You 3 was somehow built directly into QuickShell itself. However, after looking into it more closely, I realized that wasn't the case.

I started exploring the source code of projects like End4 and Caelestia, and that led me to a question: how did they manage to customize and style Qt Quick Controls so extensively?

My experience with Qt is fairly limited. Most of my previous work was with Qt Widgets, so the Qt Quick ecosystem is still quite new to me.

I'd really like to understand how these custom styles and themes are created for Qt Quick Controls. In particular, I'm interested in learning how to implement or port Material You 3 components and design principles to Qt Quick.

I'd greatly appreciate any explanations, advice, or resources on this topic.

Thank you very much!

https://redd.it/1u8kofs
@qt_reddit
Can viMarkdown be built on Linux?

Recently, I've been developing viMarkdown, which is a Markdown editor powered by Qt6.

viMarkdown screnn shot

Unfortunately, I don't currently have access to a Linux environment. Could someone try building viMarkdown with CMake and QtCreator and let me know whether it builds successfully?

viMarkdown: https://github.com/vivisuke/viMarkdown

https://redd.it/1u8qb3o
@qt_reddit
Media is too big
VIEW IN TELEGRAM
The new SkyMaterial from Qt 6.12, designed for working with indirect light, has been successfully integrated with Ecliptica game. Check out the results! We now have smooth, fluid weather and daytime transitions.

https://redd.it/1uas6iz
@qt_reddit
Ideas for Pet Projects

Hi, I've been learning Qt for two months by reading Max Schlee's book. If you have any ideas for pet-projects, I'd be happy to hear from you.

https://redd.it/1ubv262
@qt_reddit
Thinking of Switching to Qt/C++ Desktop Development Looking for Good Learning Resources

I'm considering changing my development focus and moving into desktop application development using Qt and C++. My goal is to build modern cross-platform desktop applications and eventually become proficient with Qt Widgets, Qt Core, and QML. I'm looking for recommendations on:

High-quality C++ tutorials (beginner to intermediate)

The best Udemy courses for modern C++

Good Qt courses covering Qt Core and Qt Widgets

QML and Qt Quick learning resources

Any learning roadmap for becoming productive with Qt development

If you've made a similar transition or currently work with Qt professionally, I'd love to hear what resources helped you the most and what you'd recommend avoiding.

https://redd.it/1uce0ls
@qt_reddit
Qt Quick - how to clip rounded corners

I’m fairly new to Qt, and I’m trying to implement a design that uses a lot of rounded corners. I’ve managed to achieve rounded corners using MultiEffect’s mask effect, but this seems excessively complex, and I feel like I must be missing something.

As a simple example, I’m trying to implement a popup that looks similar to the following, with the item’s background changing on hover: https://jsfiddle.net/ygtc06a5/ How could this be done?

Thanks!

https://redd.it/1uceuzq
@qt_reddit
libpyqt6.so now ships with conda-forge PyQt6 — custom Qt Designer widgets work out of the box

If you've ever tried to use a QDesignerCustomWidgetInterface subclass with PyQt6 installed via conda, you hit the same wall: Qt Designer shows "Python plugin" as failed in Help > About Plugins, because libpyqt6.so was never included in the conda package.

For pip users, pyqt6-tools provides a wrapper around Designer that sets up the path. But with conda, there was no workaround — the physical plugin file just wasn't there.

I fixed the conda-forge recipe. Since build _1 of PyQt6 6.11.0 (published June 17), the plugin is included:

conda install pyqt6=6.11.0=*_1

What changed: the pyqt6 recipe was only installing the Python package, but Qt plugins need to be in $PREFIX/plugins/designer/.

The build was already producing libpyqt6.so — the recipe just wasn't copying it to the right place. One line fix: cp -r $PREFIX/lib/python3.x/site-packages/PyQt6/Qt/plugins/ $PREFIX/plugins/

Same issue exists for PyQt5 (needs libpyqt5.so) but since Qt5 reaches EOL in December 2026, PyQt6 is the priority.

If you're building conda packages that ship Qt plugins, check that qt-plugins are in the right location. The upstream build system puts them inside the Python site-packages — conda expects them under $PREFIX/plugins/.

This was discussed on the PyQt mailing list earlier this week.

I'm posting it here in case anyone else was tracking the issue.



https://redd.it/1uaytj4
@qt_reddit
Does Qt Have a Future or Not?

Where is Qt used the most today in terms of countries, industries, and companies?

I am curious where the demand for Qt C++ developers is strongest ?

https://redd.it/1ufkoeo
@qt_reddit
How to learn shader programming for Qt 6?

Are there tutorials or walkthroughs for programming shaders on Qt 6 that you can recommend? The first thing I want to do is draw QSGGeometry lines with varying line thicknesses but I’m finding it difficult to get started.

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