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

Learning about the Model/View framework with an application using Qt 5.15

Hello. Here I'm trying to create an Qt model/view that shows different data from a model depending of the child selected/clicked in the QTreeView, but I'm new at this and the examples I'm finding does not do anything close to this. Also I'm not finding the Qt Documentation to be really clear about how to do it either.

I stored the data in a QMap just as an example data and used it to fill the model of the table, but what should I do to make the tree and the table to work together? How can I tell the model to show only the data of the child I clicked in the treeview? I read something about proxies but I'm not sure if it applies for this case. Please help me with your suggestions.

At the time I'm using a model for the treeview and another model for the tableview, that's why I have two Qmaps.

https://preview.redd.it/k9u55a274n5d1.png?width=1139&format=png&auto=webp&s=12baff461318c2f6d84cbf90935e73bc0f3dd957

This is how I set the model I used to work with the tableview.

This is how I set the model I used to work with the treeview.

https://preview.redd.it/4odspzgr7o5d1.png?width=922&format=png&auto=webp&s=1105ce247975611fdd206f3bb21ea52eba2525b6



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

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

Qt - Reddit

Move selected items as one "group"?

Hey all. I know you read the title and are probably racing to your keyboards to tell me about QGraphicsItemGroup. I don't want to use this, as I am trying to move selected items based on two QSpinBoxes (self.x\_pos\_spin, self.y\_pos\_spin):

def use_set_item_pos(self):
self.canvas.blockSignals(True)
try:
x = self.x_pos_spin.value()
y = self.y_pos_spin.value()

for item in self.canvas.selectedItems():
pass
finally:
self.canvas.blockSignals(False)

If I just use setPos(), the items don't move together, they "jump" into weird areas. I cannot figure out how to move the selected items as one whole, maybe using moveBy()? Any help is appreciated.

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

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

Qt - Reddit

Help me Regarding QOpengl with ffmpeg to render a video

Hello there, I've been trying to learn how can i make a video player, like mpv, for learning purposes, so can anyone tell me how do i do it or provide me any example.
I am able to work with qopeglwidget, rendering a texture and pass framebuffer with qimage or raw data, and I'm able to decode a video using ffmpeg, and both are working Invidiually, so now how do i use these together?
First I learnt those with glfw, and there I was just reading frame and rendering them in the main event loop, but here I don't know what do i have to do.
Any help is appreciated.

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

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

Qt - Reddit

Photoshop like panels in Qt?

Exactly what the title says. I'm wanting to create photoshop like panel management in Qt (tabs, dragging to new windows, etc.)

I understand you can use QDockWidget and QTabWidget, but what about the detaching and reattaching of tabs, then attaching detached tabs to other detatched tabs? This seems like some custom work, maybe even making custom widgets for this? I don't really know. Any help or ideas are appreciated.

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

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

Qt - Reddit

How can you replace Signals and Slots system with regular code?

Hello. I have been using Qt for more than a year. I really like the signals and slots system(as it makes sending information so much easier) , and I was wondering , how could the transmission of information that the signals and slots perform , be converted to regular code? Would you do an event loop?


For example , I have a Client and a Server. When the Client receives information from the server to update some stuff , I emit from the connection handler that xyz has changed and then the UI objects update as well. Could this be replaced by a "ServerResponseEvent" that runs over and over?


I am asking this out of curiosity , as I do not want to solely rely on signals and slots. Some times , it may make code less readable.

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

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

Qt - Reddit

Need help with cmake configuration

currently, i have been using a single cmakelist file in my root project directory as seen here https://github.com/chids04/cplayer/blob/main/CMakeLists.txt

i have refactored my directory structure now so that development is more organised and now it looks like

.
├── CMakeLists.txt
├── Main.qml
├── cpp
│   ├── cppmodels
│   │   ├── include
│   │   │   ├── album.h
│   │   │   ├── albumholder.h
│   │   │   ├── coverartholder.h
│   │   │   ├── musiclibrary.h
│   │   │   ├── musicscannerthread.h
│   │   │   ├── playlist.h
│   │   │   ├── song.h
│   │   │   └── songholder.h
│   │   └── src
│   │   ├── album.cpp
│   │   ├── albumholder.cpp
│   │   ├── coverartholder.cpp
│   │   ├── musiclibrary.cpp
│   │   ├── musicscannerthread.cpp
│   │   ├── playlist.cpp
│   │   ├── song.cpp
│   │   └── songholder.cpp
│   ├── image
providers
│   │   ├── include
│   │   │   └── mediaimageprovider.h
│   │   └── src
│   │   └── mediaimageprovider.cpp
│   ├── playback
│   │   ├── include
│   │   │   ├── mediaplayercontroller.h
│   │   │   └── playlistmanager.h
│   │   └── src
│   │   ├── mediaplayercontroller.cpp
│   │   └── playlistmanager.cpp
│   ├── qmlmodels
│   │   ├── include
│   │   │   ├── albumfilterproxymodel.h
│   │   │   ├── albumlistmodel.h
│   │   │   └── songlistmodel.h
│   │   └── src
│   │   ├── albumfilterproxymodel.cpp
│   │   ├── albumlistmodel.cpp
│   │   └── songlistmodel.cpp
│   └── views
│   ├── include
│   │   ├── albumsongsview.h
│   │   ├── albumview.h
│   │   ├── folderview.h
│   │   ├── songview.h
│   │   └── viewcontroller.h
│   └── src
│   ├── albumsongsview.cpp
│   ├── albumview.cpp
│   ├── folderview.cpp
│   ├── songview.cpp
│   └── viewcontroller.cpp
├── main.cpp
├── qml
│   ├── AlbumSongs.qml
│   ├── Albums.qml
│   ├── Folders.qml
│   ├── MainWindow.qml
│   ├── MediaSlider.qml
│   ├── Sidebar.qml
│   ├── Songs.qml
│   └── components
│   └── CButton.qml
├── resources.qrc
└── ui
├── assets
│   ├── Roboto-Black.ttf
│   ├── albumIcon.png
│   ├── icons8-music-48.png
│   ├── musicIcon.png
│   ├── mute.png
│   ├── next.png
│   ├── pause.png
│   ├── pika.png
│   ├── play.png
│   ├── previous.png
│   ├── repeat.png
│   ├── repeat
individual.png
│   ├── repeatplaylist.png
│   ├── shuffle.png
│   ├── unknownCover.png
│   └── volume.png
└── fonts
└── Satoshi-Medium.otf

do i add a cmakelist to each subdirectory and add a qt\
add_qml_module to each one? and then in the main cmakelist i use add_directory() to bring everything together. i also use an external library, taglib. would i need to link to this library in each subdirectory or can i just do it once in the root cmakelist



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

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

Qt - Reddit

QCommandLineOption question -> how to check for "-v" flag set?

I have a QCoreApplication (CLI utility). I'd like to check for the "-v" flag.

The problem is, the "-v" option is set automatically by QCommandLineOption. I don't need to override it. I'd just like to see if it's set but I don't have the option object handle.

Is there a way to do this?

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

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

Qt - Reddit

Handle platform-specific code.

I have a feature which needs to be implemented on both Android and Linux, Tried using different classes to implement the feature on different platforms.

Now my Android implementation needs QJniObject which should be included via #include<QJniObject>

which gives a compile error when building on the desktop platform.

I found using #ifdef Q_OS_ANDROID on both the header and source files, it works but it looks so awkward.

My second solution is using the same header and source files for both classes with #ifdef Q_OS_ANDROID.

So the two classes have the same name, implementing the same interface and it works fine.

Now I am new to C++ and Qt, how would you go about this ?





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

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

Qt - Reddit

Qt and openGL

I am trying to make interactive geographic information system using Qt and openGL. I am new to both of them. Where can I start?

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

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

Qt - Reddit

Qt Property Macro (Q_PROPERTY with 95% less code)
https://raymii.org/s/blog/Qt_Property_Macro_Q_PROPERTY_with_95_percent_less_code.html

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

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

Qt - Reddit

Help with QAudioSource

Hi, I am trying to achieve something like this:

mAudioIn->setNotifyInterval(100);

connect(mAudioIn, &QAudioInput::notify,this, &MainWindow::processAudioIn);

So basically, every 100ms processAudioIn function would execute.

But in Qt 6.7.1, and apparently notify was removed.
I will appreciate any help.

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

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

Qt - Reddit

Are there any QVariant benchmarks or performance notes?

I only know it does implicit sharing but I'm interested in microbenchmarks and conclusions. Ideally Qt5 and Qt6. No, I can't afford doing it myself, sadly.

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

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

Qt - Reddit

Cancel QPixmap or QImage loading?

I'm creating a simple image viewer in qt c++, and I need to find a way to cancel the image loading process. Whenever I try to quickly navigate through images, I have to wait for the previous image to finish loading before it loads the current one. I would like to stop all previous loading images in to prevent any hanging and freezing. Is it possible to use threads and forcibly terminate them once I go to another image? I would appreciate any help, thank you.

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

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

Qt - Reddit

How can I have a QTimer loop running until a condition is met?

I have a code for logging in using OAuth with callback that I handle by creating a temp file. I want to wait until the file exists and then call a method that processes the login. I have no idea what I did wrong, but it's not working at all, even after leaving just the qDebug() in the lambda without any parameters.

Settings instance = this;
QTimer timer;
timer.setInterval(1000);
QObject::connect(&timer, QTimer::timeout, &timer, &codeverifier, &instance {
qDebug() << "Running the loop...";
if (QFile::exists("<path>")) {
instance.ProcessLogin(codeverifier);
timer.stop();
}
});
timer.start();

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

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

Qt - Reddit

License when you only produce code

Hi guys,

I just read up on Qt licenses, and apart from the fact that stuff looks really complicated it was all strongly focused on "you sell/distribute an application that contains Qt". Granted, this might be the most common case. However, it is not the use case I'm interested in, so I'll ask here:

Assume I only hand out code (e.g. some small library or example on github, or maybe some freelance coding work on the side) and tell the user to get their own copy of Qt to build and run it. Are there any restrictions regarding licenses in this case (if yes: which and where do I find more information on that?), or can I put whatever license I want on my stuff as I never hand out any part of Qt to anyone, so the license restrictions don't apply in this case?

Are there restrictions on which version of Qt I can use for development (community/paid) in this case, or does it again not matter?

&#x200B;

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

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

Qt - Reddit

Qt WebAssembly listen for URL change

Hi!

Since a pure Qt WebPage is a SPA, the browser navigation doesn't work by default.

I managed to change the url from C++ by using emscripten_run_script("history.pushState()") which works quite well. I can also use emscripten::val location = emscripten::val::global("location") to get the entered url, so a user can share a specific page of the application by sharing the url.

However, atm using the browser back/forward button doesn't do anything, since I don't know how to listen to a url change after the application start without using a separate thread that basically checks the url every 100ms and compares it to the last one - which brings separate problems related to running multi threaded WASM apps.

Is there a way, e.g. by using a QEventLoop, to listen for url changes and trigger a function/emit a signal when it detects one?

Or is there an easier way to make browser navigation work?

Yes, i know this is a trivial problem in a traditional web framework like Blazor, but i f***ing hate html/css and want to try Qt QML WebAssembly. (I already know Qt).

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

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

Qt - Reddit

Cannot install properly

I'm tottally super newbie for this program. During installation, there has to be options in installation folder section. But for mine, I don't have any of them. After that I press next there is almost nothing neither.

https://preview.redd.it/3dei01sn4a5d1.png?width=1009&amp;format=png&amp;auto=webp&amp;s=b2ff9957af0d48125c56467ca57bd36910a7a7b8

https://preview.redd.it/e8rug4a95a5d1.png?width=1000&amp;format=png&amp;auto=webp&amp;s=c68bf3363938161ccc3a996b01207944d2c97963

After finishing installation there is no file to execute the program and it's just folder contains maintainer program.
What am I doing wrong here?

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

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

Qt - Reddit

MacOS, QT Designer 6.7.1 breaks it for me, please help

MacOS 13.6.7

Homebrew OS installation:
Python 3.12 + PySide 6.7.0 => virtual environment = all forms work in Designer 6.7.0

PyCharm setup:
Python 3.10 + PySide 6.7.1 = can’t edit forms, all x,y,width,height fields are set to ‘0’ and can’t be changed

Background:
Homebrew wiped my Python 3.9 + PySide 6.6 of the disk yesterday and since I had 3.9 setup in PyCharm as Python interpreter I had to setup new environment. So, I did setup 3.10 and fetched the import modules new. Instead of getting PySide 6.7.0 (like the one from Homebrew) I got PySide 6.7.1 which broke it…

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

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

Qt - Reddit

Aero snap etc for custom titlebar qt

So we're making a qt based app that has a custom titlebar with custom close ,open and minimise buttons as well ,could anyone tell us how to get features like aero snap and window animations working for that in windows , we've tried a few things we've seen on GitHub and stack overflow but it hasn't really been working, can anyone suggest how we could achieve this.

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

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

Qt - Reddit

background color bleed thru UI

I am trying to achieve the effect now present in ios 17 where the background color bleeds thru to the UI elements/text so whatever the background color is you get a nice hue effect in the text and ui elements

is this possible with qml ? if so could you point me to an example.

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

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

Qt - Reddit

Help with simple code needed

I was trying to create a small list editor by following this tutorial (https://youtu.be/Qo2trwCPj3M?si=yI0MMzvucBdv9k2j). However, I keep getting an error saying that the app quit unexpectedly, which doesn't happen in the video. My code is almost the same as in the tutorial. The only difference is that the author of the video is using Windows, while I am on a Mac. However, I don't see how that could be causing the problem.



I just started learning Qt and C++, so if you have any resources that might be helpful for a beginner, I would appreciate it too. Thanks!


#include "mainwindow.h"

#include "./ui_mainwindow.h"

#include <QFile>

#include <QMessageBox>

#include <QStandardPaths>



//Constructor

MainWindow::MainWindow(QWidget *parent)

: QMainWindow(parent)

, ui(new Ui::MainWindow)

{

ui->setupUi(this);

//Load and save

QFile file(QStandardPaths::writableLocation(QStandardPaths::DesktopLocation) + "\\\\FileSaved.txt");



if(!file.open(QIODevice::ReadWrite)){

QMessageBox::information(0, "EWWWWW", file.errorString());

}



QTextStream in(&file);



while(!in.atEnd()){

QListWidgetItem* item = new QListWidgetItem(in.readLine(), ui->listWidget);

ui->listWidget->addItem(item);

item->setFlags(item->flags() | Qt::ItemIsEditable);

}



file.close();



}



//Destructor

MainWindow::\~MainWindow()

{

delete ui;

//Load and save

QFile file(QStandardPaths::writableLocation(QStandardPaths::DesktopLocation) + "\\\\FileSaved.txt");



if(!file.open(QIODevice::ReadWrite)){

QMessageBox::information(0, "EWWWWW", file.errorString());

}



QTextStream out(&file);



for (int i = 0; i < ui->listWidget->count(); ++ i) {

out << ui->listWidget->item(i)->text()<<"\\n";

}

file.close();

}

//Add button

void MainWindow::on_pushButton_add_clicked()

{

QListWidgetItem* item = new QListWidgetItem(ui->lineEdit_userInput->text(), ui->listWidget);

ui->listWidget->addItem(item);

item->setFlags(item->flags() | Qt::ItemIsEditable);

ui->lineEdit_userInput->clear(); // clear line edit once done entering

ui->lineEdit_userInput->setFocus();

}

//Remove button

void MainWindow::on_pushButton_remove_clicked()

{

QListWidgetItem* item = ui->listWidget->takeItem(ui->listWidget->currentRow());

delete item;

}

//Reset all button

void MainWindow::on_pushButton_reset_clicked()

{

ui->listWidget->clear();

}



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

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

Qt - Reddit

Best Learning Order of QT

I want to build a desktop application. After a little bit of research, I started to learn by reading the official tutorial https://doc.qt.io/qt-6/qt-intro.html

However, I often feel overwhelmed because a tutorial can link to numerous other ones, and it seems I have infinite things to learn before I can start my project. Also, it seems the pages have similar information of the same topic in multiple places, which confuses me a lot.

Can anyone suggest a good learning order? I want to learn the essentials and then start doing the project. I plan to use Qt6 and learn QML, QT Design Studio, C++ for QT.

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

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

Qt - Reddit

Best Way to Add Image Views to a Dock Widget in PyQtGraph?

Hi everyone,

I'm trying to add image views to a dock widget. Specifically, I want to create a layout where the dock widget has two rows, with each row containing an image view.

I've been exploring different approaches but haven't found a clear, efficient method to achieve this. Could anyone share the best practices or code examples for adding multiple image views to a dock widget in this specific layout?

Any advice or pointers to relevant documentation would be greatly appreciated!

Thanks in advance!

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

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

Qt - Reddit

Qt and Smart Pointers

I’ve been getting back into C++ after many years, and trying to get up to speed on smart pointers. I’ve seen comments about conflicts between Qt and smart pointers? For classes like models and custom classes the inherit QObject, is it a good idea to encapsulate instances in smart pointers when initiated as a pointer? Are there any decent discussions on smart pointers in context of Qt best practices? I have Googled, but didn’t really find much in the chaos of the Interwebs.


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

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

Qt - Reddit

Support My C++/Qt Project: Physioform - An AI-Driven Physiotherapy Center Management App
https://youtu.be/NLGwSmVQclI?si=zcmNmD5lD5401V1W

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

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

Qt - Reddit

Ui editor crashes every couple of changes

&#x200B;

https://reddit.com/link/1d50nm6/video/veabm2f8ns3d1/player

Honestly it's so fucking annoying I have to save every time I make a change

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

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

Qt - Reddit

building on my laptop and on github actions

I am tring to build an desktop app in qt. So code compiles - now, lets make a windows installer

My build is:

      - name: Build
working-directory: ${{ github.workspace }}
id: runcmakebuild
run: |
cmake --build "build/${{ matrix.config.build_dir }}" --parallel --verbose
- name: Install
working-directory: ${{ github.workspace }}
id: runcmakeinstall
run: |
cmake --install "build/${{ matrix.config.build_dir }}" --prefix="dist/${{ matrix.config.build_dir }}/usr"


I can create a usable app image from this. Nice. Now - lets make a windows installer. So, I started doing this locally - using this batch file:

@echo on

SET matrix_config_build_dir=windows-msvc
SET PATH=c:\Qt\6.7.1\msvc2019_64\bin\;c:\Program Files (x86)\Inno Setup 6\;%PATH%

rem call "C:\Program Files\Microsoft Visual Studio 9.0\VC\bin\vcvars32.bat"
rem call "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars32.bat"
rem call "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat"
call "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" x64

rem cmake -B "build/%matrix_config_build_dir%" -DCMAKE_BUILD_TYPE=Release -DCMAKE_GENERATOR_PLATFORM=x64
rem cmake --build "build/%matrix_config_build_dir%" --parallel --verbose
cmake --install build/%matrix_config_build_dir% --prefix=dist/%matrix_config_build_dir%/usr

windeployqt --release --no-translations --no-system-d3d-compiler --no-compiler-runtime --no-opengl-sw dist/%matrix_config_build_dir%/usr/bin/qtedit4.exe

iscc setup_script.iss


Problems:
on github - I can use ninja as the generator, on my laptop, using ninja spits "does not support platform specification, but platform" (removing -G fixes it). I am unsure why on my laptop this fails
the install command (cmake --install) fails - this is the error I see:
-- Install configuration: "Release"
CMake Error at build/windows-msvc/cmake_install.cmake:49 (file):
file INSTALL cannot find
"C:/Users/ignorantpisswalker/Documents/qtedit4/build/windows-msvc/Release/qtedit4.exe":
No error.

again - this setup works on github, but locally fails.

How can I replicate the setup Github has locally? How can I fix the problems above?

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

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

Qt - Reddit

ninja: error: '/usr/lib/libQt5Widgets.so.5.15.13', needed by 'yt-dlp-gui', missing and no known rule to make it

https://preview.redd.it/jvqutx97cl3d1.png?width=1062&amp;format=png&amp;auto=webp&amp;s=c2be96e29568a2e394b17e0dead35afeb8915da5

I use arch linux btw

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

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

Qt - Reddit

The new windows 11 theme...

is that a joke?
Really, it looks awful by default! Or I am doing something wrong? For instance the designer tool has a default white background while the preview has a solid color background.

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

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

Qt - Reddit

I just need QT creator on Mac

Some video I watched about Vulkan was using QT creator but it was windows

Going to YouTube to see how to install the same, I instead got one that was about installing QT open source (community) are they the same thing, and if not, how to get QT creator for Mac(for free)?

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

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