Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.6k Topics 457.3k Posts
  • The dreaded 0xc000007b error

    Solved
    4
    0 Votes
    4 Posts
    385 Views
    R
    @rjmx Found the missing DLL. Problem solved.
  • compiling to 64 bits ok How do I configure 32 bits static?

    Unsolved
    5
    0 Votes
    5 Posts
    416 Views
    J
    @SimonSchroeder How do I do that for what?
  • Grid layout widget and splitter-like resizing

    Unsolved grid gridlayout splitter
    9
    0 Votes
    9 Posts
    4k Views
    A
    @KenAppleby-0 I have an extremely stupid proof of concept that sort of does what I describe in the initial message, it's extremely rough and should not be considered a good idea by anybody, but here goes: from PyQt6.QtWidgets import QWidget, QPushButton, QGridLayout, QSizePolicy, QApplication from PyQt6.QtGui import QColor, QPalette from PyQt6.QtCore import Qt class BorderWidget(QWidget): def __init__(self, widget_id, side, layout=None, row=None, column=None): super(BorderWidget, self).__init__() self.widget_id = widget_id self.side = side self.layout = layout self.row = row self.column = column pal = self.palette() pal.setColor(QPalette.ColorRole.Window, QColor('white')) self.setAutoFillBackground(True) self.setPalette(pal) self.pressed = False def mousePressEvent(self, event): super(BorderWidget, self).mousePressEvent(event) print(f"Clicked on {self.side} border of widget {self.widget_id}") print(f"self.press is {self.pressed}") self.pressed = True self.last_x = event.globalPosition().x() self.last_y = event.globalPosition().y() def mouseReleaseEvent(self, event): self.pressed = False def mouseMoveEvent(self, event): if self.pressed and self.layout is not None: dx = event.globalPosition().x() - self.last_x self.last_x = event.globalPosition().x() dy = event.globalPosition().y() - self.last_y self.last_y = event.globalPosition().y() if dx != 0: if self.side in ['right', 'left']: new_stretch = max(1, self.layout.columnStretch(self.column) - dx) self.layout.setColumnStretch(self.column, int(new_stretch)) elif self.side in ['bottom', 'top']: new_stretch = max(1, self.layout.rowStretch(self.row) - dy) self.layout.setRowStretch(self.row, int(new_stretch)) class DraggableWrapper(QWidget): def __init__(self, widget, widget_id, main_layout, row, column): super(DraggableWrapper, self).__init__() self.layout = QGridLayout(self) self.layout.setSpacing(0) self.layout.setContentsMargins(0, 0, 0, 0) self.border_top = BorderWidget(widget_id, 'top', main_layout, row, column) self.border_bottom = BorderWidget(widget_id, 'bottom', main_layout, row + 1, column) self.border_left = BorderWidget(widget_id, 'left', main_layout, row, column) self.border_right = BorderWidget(widget_id, 'right', main_layout, row, column + 1) self.border_top_left_horizontal = BorderWidget(widget_id, 'topleft', main_layout, column) self.border_top_right_horizontal = BorderWidget(widget_id, 'topright', main_layout, column) self.border_bottom_left_horizontal = BorderWidget(widget_id, 'bottomleft', main_layout, column) self.border_bottom_right_horizontal = BorderWidget(widget_id, 'bottomright', main_layout, column) self.layout.addWidget(widget, 1, 1) self.layout.addWidget(self.border_top, 0, 1) self.layout.addWidget(self.border_bottom, 2, 1) self.layout.addWidget(self.border_left, 0, 0, 3, 1) # cover the corners self.layout.addWidget(self.border_right, 0, 2, 3, 1) # cover the corners self.layout.addWidget(self.border_top_left_horizontal, 0, 0) self.layout.addWidget(self.border_top_right_horizontal, 0, 2) self.layout.addWidget(self.border_bottom_left_horizontal, 2, 0) self.layout.addWidget(self.border_bottom_right_horizontal, 2, 2) border_width = 10 self.border_top.setFixedHeight(border_width) self.border_bottom.setFixedHeight(border_width) self.border_left.setFixedWidth(border_width) self.border_right.setFixedWidth(border_width) # apply size restrictions to corner border widgets to form L-shaped corners self.border_top_left_horizontal.setFixedSize(border_width, border_width) self.border_top_right_horizontal.setFixedSize(border_width, border_width) self.border_bottom_left_horizontal.setFixedSize(border_width, border_width) self.border_bottom_right_horizontal.setFixedSize(border_width, border_width) # Apply size policies self.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding) widget.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding) class MainWindow(QWidget): def __init__(self): super().__init__() layout = QGridLayout(self) layout.setSpacing(0) default_stretch = 300 layout.setRowStretch(0, default_stretch) layout.setRowStretch(1, default_stretch) layout.setColumnStretch(0, default_stretch) layout.setColumnStretch(1, default_stretch) widget1 = QPushButton("Button 1") wrapper1 = DraggableWrapper(widget1, '1', layout, 0, 0) widget2 = QPushButton("Button 2") wrapper2 = DraggableWrapper(widget2, '2', layout, 0, 1) widget3 = QPushButton("Button 3") wrapper3 = DraggableWrapper(widget3, '3', layout, 1, 0) widget4 = QPushButton("Button 4") wrapper4 = DraggableWrapper(widget4, '4', layout, 1, 1) layout.setContentsMargins(0, 0, 0, 0) layout.addWidget(wrapper1, 0, 0) layout.addWidget(wrapper2, 0, 1) layout.addWidget(wrapper3, 1, 0) layout.addWidget(wrapper4, 1, 1) if __name__ == '__main__': app = QApplication([]) mainWin = MainWindow() mainWin.setMinimumSize(800, 800) mainWin.show() app.exec()
  • Qt Installer Crash

    Unsolved
    3
    0 Votes
    3 Posts
    343 Views
    T
    Hi! Any updates? I have the same problem.
  • I want implement SCRAM ( RFC5802 ) in QT5, is there some useful library?

    2
    0 Votes
    2 Posts
    644 Views
    NeustradamusN
    @redbit Now QCA has changed since your original topic. https://invent.kde.org/libraries/qca https://github.com/KDE/qca But there is always a problem -PLUS variants do not work. I always need help of contributors to add the support of -PLUS variants. There is a ticket here: https://bugreports.qt.io/browse/QTBUG-77783 A not-complete list of supported softwares: https://github.com/scram-sasl/info/issues/1 Linked to: https://tools.ietf.org/html/rfc5929 https://tools.ietf.org/html/rfc9266 https://tools.ietf.org/html/rfc9266 https://xmpp.org/extensions/xep-0388.html https://xmpp.org/extensions/xep-0440.html https://xmpp.org/extensions/xep-0474.html https://www.iana.org/assignments/channel-binding-types/channel-binding-types.xhtml Jabber.ru MITM: https://notes.valdikss.org.ru/jabber.ru-mitm/ https://snikket.org/blog/on-the-jabber-ru-mitm/ https://www.devever.net/~hl/xmpp-incident https://blog.jmp.chat/b/certwatch
  • How can I change the QTreeView branch indicator width in the stylesheet?

    Moved Unsolved
    5
    0 Votes
    5 Posts
    425 Views
    SGaistS
    @Bob64 Topic moved
  • Problems creating mysql plugin in Qt6.6 on linux

    Solved
    5
    0 Votes
    5 Posts
    700 Views
    Christian EhrlicherC
    Nice to hear, please mark the topic as solved then.
  • Configurable QSlider/QDial that uses double values

    Unsolved
    3
    0 Votes
    3 Posts
    438 Views
    S
    @KenAppleby-0 said in Configurable QSlider/QDial that uses double values: It really isn't. Perhaps you could define and refine what you would call "intuitive" and then you would see why. To implement, that is, but I will try your suggestion to create a customizable class... thank you.
  • Widget' object has no attribute 'pushButton'

    Solved
    2
    0 Votes
    2 Posts
    1k Views
    C
    @xavi-hachem Please place code in a code block otherwise we will be guessing the indenting and having to piece together code that is mangled. This is the </> icon on the editor tool bar or type three backticks before and after the block. Anyway, you need to put loaded UI into a persistent member variable: import os from pathlib import Path import sys from PySide2 import QtCore, QtGui, QtWidgets from PySide2.QtWidgets import QApplication, QWidget, QPushButton from PySide2.QtCore import QFile from PySide2.QtUiTools import QUiLoader class Widget(QWidget): def __init__(self): super(Widget, self).__init__() self.load_ui() self.ui.pushButton.clicked.connect(self.hello_world) # ^^^^^ use the UI through the member variable def load_ui(self): loader = QUiLoader() path = os.fspath(Path(__file__).resolve().parent / "Application.ui") ui_file = QFile(path) ui_file.open(QFile.ReadOnly) self.ui = loader.load(ui_file, self) # ^^^^^ put the loaded UI into a member variable ui_file.close() def hello_world(self): print("Hello world") if __name__ == "__main__": QtCore.QCoreApplication.setAttribute(QtCore.Qt.AA_ShareOpenGLContexts) app = QApplication([]) widget = Widget() widget.show() sys.exit(app.exec_()) Alternatively use pyside2-uic/ pyside6-uic and get a range of advantages. BTW: Are you really mixing PySide2 and PyQt5?
  • Touchscreen QPushButton does not emit released()

    Unsolved
    14
    0 Votes
    14 Posts
    1k Views
    bigguinessB
    @JoeCFD thanks for the leads. I have it working now using event() to handle the touch events instead of using the normal mouse events. A couple notes about this. Setting the Qt::WA_AcceptTouchEvents attribute disables all the normal moue events. Instead of the mousePressEvent() -> emit pressed() happening, you get an event() with either a QEvent::TouchBegin or QEvent::TouchUpdate. You then have to figure out what button the touch points are associated with. Then you need to handle the "pressed" and setDown(true) the button. As long as any touch is still present you will periodically get an event() with QEvent::TouchUpdate. This also happens instead of a mouseMoveEvent(). Only the touches still active will be in the touch points. If a touch you are interested in is not in the points, that associated button will need to be "released" and setDown(false). Instead of a mouseReleaseEvent() -> emit released(), when all touches are released you will get an event() with QEvent::TouchEnd with the touch points of the final released touches. Again these need to be associated to buttons that need to be "released" and setDown(false). In my case I'm only interested in the first touch so I ignore all QTouchEvent::TouchPoint id() != 0. This seems to be something that Qt should be able to handle internally. But.... Oh well...
  • This topic is deleted!

    Solved
    7
    0 Votes
    7 Posts
    8 Views
  • QSplashScreen after startup?

    Unsolved
    8
    0 Votes
    8 Posts
    705 Views
    richferraraR
    @Pl45m4 Never mind ... I found a memory error in my code. I think that was the problem.
  • Qt6 yocto build - filesystem no such file

    Unsolved
    1
    0 Votes
    1 Posts
    229 Views
    No one has replied
  • QBitArray instantiate with a sequence of bits

    Unsolved
    2
    0 Votes
    2 Posts
    229 Views
    J.HilkJ
    @roditu you don't initialiser list is not supported for QBitArray or for QByteArray you can use the from bits function correctly: const char *data = "\x7"; // 1110 in binary depending on endian QBitArray bits = QBitArray::fromBits(data, 4); keep in mind, that data needs to live as long as bits! or you could make a helper function : QBitArray bitArrayFromList(std::initializer_list<bool> list) { QBitArray bits(list.size()); int i = 0; for (bool b : list) { bits[i] = b; ++i; } return bits; } QBitArray bits = bitArrayFromList({true, true, true, false}); qDebug() << bits << bits[0] << bits[1] << bits[2] << bits[3]; //QBitArray(1110) true true true false
  • Force aspect ratio on window

    Unsolved
    3
    0 Votes
    3 Posts
    287 Views
    G
    @SamiV123 Is there no built in feature for this?
  • This topic is deleted!

    Unsolved
    3
    0 Votes
    3 Posts
    182 Views
  • Run Qt Gui in separate thread

    Unsolved
    11
    0 Votes
    11 Posts
    3k Views
    S
    @J-Hilk said in Run Qt Gui in separate thread: @SamiV123 said in Run Qt Gui in separate thread: About Qt I don't know. I can see failure modes if some bad engineering is done. there's one major problem with creating a Thread via QThread that then contains the QCoreApplication instance. QThread is a QObject. And QCoreApplication or one of its derivatives NEEDS to be the first QObject to be instantiated. One of the reasons static QObjects are prohibited Yep, but you can always use CreateThread, std::thread for example.
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    3 Views
    No one has replied
  • QPrintPreviewDialog print all pages though page range is selected

    Unsolved
    3
    0 Votes
    3 Posts
    471 Views
    A
    I encountered same issue (it is mentioned even in official QT doc, that this functionality depends on operating system). However there is a way to workaround it. The idea is to create new QPrinter object, also with new QPainter. Then you pass them the print settings catched in preview dialog and render only desired pages from your data source, for example: rangePainter.begin(pageRangePrinter); for(int i = from; i <= to; i++) { yourDataSource[i-1]->view->render(&rangePainter); if (i != printer->toPage() ) { pageRangePrinter->newPage(); } } rangePainter.end(); So in fact, you print using another QPrinter object. However there is an important point to overcome. If user clicks "Print" in preview dialog, signal paintRequested() is emitted 2nd time and probably your logic showing preview before, will fire itself again and the printer will start printing all pages + pages in range (from logic above). I think there are many ways to manage with it, but one is to disconnect this signal after 1st emit (1st emit is being done when user request to show preview dialog). I hope it will help
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    3 Views
    No one has replied