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 Resize Handles for a QGraphicsItem?

Hey everyone.

I'm looking to create resize handles for any QGraphicsItem, similar to what you'd see in Photoshop. I'm wondering how I would accomplish this in PyQt. I need it to work for any QGraphicsItem so I don't have to subclass each item and apply logic internally. I was thinking about using QTransform for this, as it works for any item for scaling.

The handles need to work for any QGraphicsItem without subclassing each item and applying logic internally. I'm considering using QTransform because it works for any item for scaling. In summary, here's what I'm trying to achieve:

A screenshot of the resize handles in Adobe Illustrator

Any help or suggestions are greatly appreciated.

https://redd.it/1cr2cji
@qt_reddit
How to create rulers on sides of QGraphicsView in PyQt5?

Good day all. I am trying to achieve this in PyQt:

https://preview.redd.it/1yf01fmdko0d1.png?width=414&format=png&auto=webp&s=11c6a050c756687cc0947a4f7255c6b8e8628fdd

I have read countless Stack Overflow threads and searched Github, but all I have found are C++ versions of the rulers. I basically need a Python version of the rulers, I don't know if anybody has done this with PyQt. Any help is appreciated.

https://redd.it/1cszxfl
@qt_reddit
Error while installing QT on my desktop

I get this error while trying to install Qt on my desktop. It usually starts at around 2% of the installation process. Anything I can do to fix this?

https://preview.redd.it/y08isju6lr0d1.jpg?width=509&format=pjpg&auto=webp&s=a1fc2fb35346502e7d6139f4311fd8108bafd11e



https://redd.it/1ct9m6v
@qt_reddit
What's the easiest way to distribute a PyQt6 app for multiple OS?

Hi, I made a PyQt6 onefile app with PyInstaller and want to distribute it for Windows and MacOS. Is making a virtual machine for each OS and building it on them the best way, or are there better alternatives?

https://redd.it/1cu3676
@qt_reddit
Qt on lemmy?

Is there any Qt framework related community on lemmy? I can't find just by typing 'qt'. It didn't have auto suggestion like reddit.

https://redd.it/1cum9ek
@qt_reddit
Qt frameless window does not resize or move as expected on KDE

I have created a QMainWindow with the following window flags Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint | Qt::BypassWindowManagerHint like so
BrowserWindow::BrowserWindow(QWidget parent, double width, double height): QMainWindow(parent), resizing(false){
this->resize(width, height);
this->setWindowFlags(Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint | Qt::BypassWindowManagerHint);
this->setAttribute(Qt::WA_TranslucentBackground);
this->setMouseTracking(true);

//Implement Outer UI
QWidget
centralWidget = new QWidget(this);

//...widgets
centralWidget->setMouseTracking(true);


this->setCentralWidget(centralWidget);
}
Here is the code I've written to implement resizing
void BrowserWindow::mousePressEvent(QMouseEvent event){
if(event->button() == Qt::LeftButton && this->isEdgePosition(event->position())){
this->showNormal();
this->resizing = true;
this->maximized = false;
this->originalGeometry = this->geometry();
this->lastMousePosition = event->globalPosition();
this->currentEdgePosition = this->edgePosition(event->position());
}
QMainWindow::mousePressEvent(event);
}

void BrowserWindow::mouseMoveEvent(QMouseEvent
event){
switch(this->edgePosition(event->position())){
case WindowBoundary::TOP:
case WindowBoundary::BOTTOM:
this->setCursor(Qt::SizeVerCursor);
break;
//...the same for the other edges and corners
default:
this->setCursor(Qt::ArrowCursor);
}

if(this->resizing){
QPointF delta = event->globalPosition() - lastMousePosition;
QRect newGeometry = originalGeometry;

switch(this->currentEdgePosition){
case WindowBoundary::TOP:
newGeometry.setTop(originalGeometry.top() + delta.y());
break;
case WindowBoundary::BOTTOM:
newGeometry.setBottom(originalGeometry.bottom() + delta.y());
break;
case WindowBoundary::LEFT:
newGeometry.setLeft(originalGeometry.left() + delta.x());
break;
case WindowBoundary::RIGHT:
newGeometry.setRight(originalGeometry.right() + delta.x());
break;
case WindowBoundary::TOPLEFT:
newGeometry.setTop(
originalGeometry.top() + delta.y());
newGeometry.setLeft(originalGeometry.left() + delta.x());
break;
case WindowBoundary::TOP
RIGHT:
newGeometry.setTop(originalGeometry.top() + delta.y());
newGeometry.setRight(originalGeometry.right() + delta.x());
break;
case WindowBoundary::BOTTOMLEFT:
newGeometry.setBottom(originalGeometry.bottom() + delta.y());
newGeometry.setLeft(originalGeometry.left() + delta.x());
break;
case WindowBoundary::BOTTOM
RIGHT:
newGeometry.setBottom(originalGeometry.bottom() + delta.y());
newGeometry.setRight(originalGeometry.right() + delta.x());
break;
}

this->setGeometry(newGeometry);
}
QMainWindow::mouseMoveEvent(event);
}
Here is the code I use to move the window.
void TitleBar::mousePressEvent(QMouseEvent event){
this->moving = true;
this->originalPosition = event->globalPosition();
this->originalGeometry = this->window->geometry();
QWidget::mousePressEvent(event);
}

void TitleBar::mouseMoveEvent(QMouseEvent
event){
if(this->moving){
QPointF delta = event->globalPosition() - this->originalPosition;
QRect newGeometry = this->originalGeometry;

newGeometry.moveTopLeft(this->originalGeometry.topLeft() + delta.toPoint());

this->window->setGeometry(newGeometry);
}
}
Here is the issue: The window does not move when clicking and dragging on the titlebar on kde, and only the bottom, right and bottom right edges resize correctly. When resizing from the top, left or top left edges/corner, it resizes from the
bottom, right or bottom right edge/corner. I have tested the same code on pop os and it resizes and moves correctly.
What can I do to ensure the same behaviour on kwin and non kwin environments?

https://redd.it/1curpls
@qt_reddit
Cannot register namespace enum

I have an enum that I need to use both in QML and C++, so I followed a reddit post here and documentation:
[https://www.reddit.com/r/QtFramework/comments/18d1o5t/how\_can\_i\_expose\_an\_c\_enum\_to\_qml/](https://www.reddit.com/r/QtFramework/comments/18d1o5t/how_can_i_expose_an_c_enum_to_qml/)
[https://doc.qt.io/qt-6/qqmlengine.html#qmlRegisterUncreatableMetaObject](https://doc.qt.io/qt-6/qqmlengine.html#qmlRegisterUncreatableMetaObject)

so I have this code:

#include <QObject>

namespace AuthStatus
{
Q_NAMESPACE
enum class Status {
LoggedIn,
TokensPresent,
None
};
Q_ENUM_NS(Status)
}

qmlRegisterUncreatableMetaObject(AuthStatus::staticMetaObject, "socialhub", 1, 0, "AuthStatus", QStringLiteral("Access to enums only"));

but when I compile it with make, I get this error:

main.cpp:(.text+0xbbe): undefined reference to `AuthStatus::staticMetaObject'

https://redd.it/1cuu0l3
@qt_reddit
Is there a better way to insert units in my form?

I wonder if there is a better way to insert the unit of my form while someone is entering a number.

TBH if I would know how to do this I would allow the user to enter its Value in inch as well as in mm.

I have no clue how this is done 'the Qt way'


Thanks in advance for any hint.

TextField{
id: innerDia
text: ""
placeholderText: "Innendurchmesser in mm"
onTextChanged: {
if (!innerDia.text.endsWith("mm"))
innerDia.text = innerDia.text + " mm"
// place curser before "mm"
innerDia.cursorPosition = innerDia.text.length - 3
}
}

https://redd.it/1cuw0d6
@qt_reddit
Dynamic QML component

It is better use C++ for dynamic QML component or Javascript Dynamic QML compinent.

In C++:
Q_INVOKABLE void createComponent(const QString &qmlCode, QObject *parent = nullptr);

In Javascript:
const newObject = Qt.createQmlObject('some string');

Which is better and why ?
I feel easier in JS, but I want to utilize C++, I want experts suggestion on which one to take when and why.

https://redd.it/1cvgnfk
@qt_reddit
Why their are less tutorials around qt or qt-qml?

I want to develop some software for realtime data, but I could not find any good resources and guide for qt. I want to create prototype projects with qt and map where rider location is realtime track by desktop app. But issue is the I could not find the resources. I find few examples code by qt and documentation around it but not a comprehensive tutorial around?

https://redd.it/1cvk94n
@qt_reddit
Qt Zipfiles

I am new to Qt and have a project that needs to be migrated to Qt 6. In our project, we normally use QuaZip, but I think we need to switch to QZipReader and QZipWriter from the Qt framework. Will this migration be straightforward? Are there any functionalities in QuaZip that QZipReader and QZipWriter do not support?

https://redd.it/1cvuikk
@qt_reddit
Help identifying a crash

Hi,

I am debugging a crash, which I cannot understand. The way I can reproduce this is:
        QString l = "\r";
QChar c = l[0];


This crashes inside the operator, relevant code from 6.7.1:
const QChar QString::operator[](qsizetype i) const
{
verify(i, 1); // this one fails me
return QChar(d.data()[i]);
}

Q_ALWAYS_INLINE constexpr void verify([[maybe_unused]] qsizetype pos = 0,
[[maybe_unused]] qsizetype n = 1) const
{
Q_ASSERT(pos >= 0);
Q_ASSERT(pos <= d.size);
Q_ASSERT(n >= 0);
Q_ASSERT(n <= d.size - pos); // here d.size is 0!!!11
}


Code does work if I change l = "1". What am I missing here?

https://redd.it/1cvzh7c
@qt_reddit
Cahier - Advanced note-taking with bibliography management (v0.5.0 release)

Hello!

Cahier is the app that I've been developing for a year and a half, written using Qt. It is a knowledge base created to support out of the box the research workflow. It allows you to both store and read study documents (PDFs, web pages, etc.), extract and link highlights from those documents, and produce written content based on them.

It's a local-first, native application for Windows and macOS.

v0.5.0 introduces better support for highlight links. Notes can be linked to highlights using cards. The startup speed is better. We've recently also added Markdown export in notes and improved the design of macOS apps.

For a more comprehensive list of changes, check our Twitter. Download the software here.

https://redd.it/1cweg8b
@qt_reddit
How can I integrated a Qml project to Android studio project

I have a qt quick project management by Qt creator. It can direct building to a apk. But I have seen someone
Use android java code to start a qt quick project.How to do that? Someone tell more information, thanks a lot !

https://redd.it/1cwfkfl
@qt_reddit
Adobe Illustrator like Pen Tool on a QGraphicsScene

Thought I'd come on here and ask this:

How would I create an Adobe Illustrator like pen tool for my QGraphicsScene? (e.g. click point by point to define the geometry and click and drag to draw curves)

I am familiar with QPainterPath and it's respective methods, but I came here to ask how the hell I would achieve this. Any help is appreciated.

https://redd.it/1cwj1im
@qt_reddit
Openssl library ARM execution TLS and Incompatible version of OpenSSL Failure

Version : Qt5.14.2
Host : Ubuntu 22


I am trying to run an Application to use http url images(for display) that uses the openssl 1.1.1d version for the Qt Framework on the ARM platoform. I was able to build the openssl 1.1.1d for ARM and load the library into the device, also have set the ld path in the /etc/ld.so.conf. After all that, I have built and link the sample Application and it throws the following error

QSslSocket Build "OpenSSL 3.0.7 1 Nov 2022" qt.network.ssl: Incompatible version of OpenSSL (built with OpenSSL >= 3.x, runtime version is < 3.x) QSslSocket Version 0 supportsSsl false

I have also tried moved out the openssl 3.0 libraries to a tmp folder. But still it throws the same error. However I was able to build the openssl 1.1.1d on x86 and run the sample-Application with success using http url images.

QSslSocket Build "OpenSSL 1.1.1d 10 Sep 2019"

QSslSocket Version 269488207

supportsSsl true

What is going wrong on the deivce, is it the build steps or the device needs to configure properly? CMAKE for ARM, below the path is shown in the link file for both vars OPENSSL\_SSL\_LIB, OPENSSL\_CRYPTO\_LIB:

set(SSL_PATH "$ENV{SDKTARGETSYSROOT}/usr/local/lib")
find_library(OPENSSL_SSL_LIB
NAMES "libssl.so"
NAMES_PER_DIR
REQUIRED
HINTS ${SSL_PATH}
PATHS ${SSL_PATH}
NO_DEFAULT_PATH)

find_library(OPENSSL_CRYPTO_LIB
NAMES "libcrypto.so"
NAMES_PER_DIR
REQUIRED
HINTS ${SSL_PATH}
PATHS ${SSL_PATH}
NO_DEFAULT_PATH)
set(CMAKE_INSTALL_RPATH "/usr/local/lib")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
add_executable(helloworld main.cpp mainwindow.cpp mainwindow.ui resources.qrc) target_link_libraries(helloworld-image
Qt5::Core
Qt5::Network
Qt5::Widgets
${OPENSSL_SSL_LIB}
${OPENSSL_CRYPTO_LIB})



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