Skip to content
  • 0 Votes
    10 Posts
    426 Views
    SGaistS

    @Pl45m4 nope, I understood ;-) I wanted to know why additional letter was needed since it's not how QSyntaxHighlighter works as you correctly explained.

  • 0 Votes
    2 Posts
    490 Views
    I

    I've found a solution, albeit with a small bit of help from ChatGPT as a last resort. I used an if/else statement (in the form of a ternary operator) for my main.qml and added an additional @Slot() decorator for the LED off function in my main,py.
    .
    .
    ↓ main.qml ↓

    import QtQuick import QtQuick.Controls ApplicationWindow { width: 1920 height: 1080 visible: true // Bool property to hold the button state property bool buttonState: false // Function to toggle the LEDs function toggleLEDs() { buttonState ? controlPanel.buttonOff() : controlPanel.buttonOn(); buttonState = !buttonState; } Image { id: allLights source: "images/power_" + (buttonState ? "on" : "off") + ".png" anchors.centerIn: parent MouseArea { anchors.fill: parent onClicked: { toggleLEDs(); } } } }

    .
    .
    ↓ main,py ↓

    import sys from pathlib import Path from led import grid, all_lights_on, all_lights_off from PySide6.QtCore import QObject, Slot from PySide6.QtGui import QGuiApplication from PySide6.QtQml import QQmlApplicationEngine class ControlPanel(QObject): def __init__(self): super().__init__() @Slot() def buttonOn(self): all_lights_on(grid) @Slot() def buttonOff(self): all_lights_off(grid) if __name__ == '__main__': app = QGuiApplication(sys.argv) engine = QQmlApplicationEngine() controlPanel = ControlPanel() engine.rootContext().setContextProperty("controlPanel", controlPanel) qml_file = Path(__file__).parent / 'main.qml' engine.load(qml_file) if not engine.rootObjects(): sys.exit(-1) sys.exit(app.exec())
  • 0 Votes
    2 Posts
    544 Views
    A

    It turned out the error I needed to research specifically was ERROR:zygote_host_impl_linux.cc(100). I found a solution here:

    https://stackoverflow.com/questions/62284578/docker-errorzygote-host-impl-linux-cc89-running-as-root-without-no-sandb

    And the new Dockerfile is

    # Use the official Python base image FROM python:3.11-bullseye RUN pip install numpy && pip install setuptools # Copy the debPackages.txt file COPY debPackages.txt . # Install Qt6 dependencies RUN apt-get update && apt-get install $(grep -vE "^\s*#" debPackages.txt | tr "\n" " ") -y # Set the working directory in the container WORKDIR /app # Copy the requirements.txt file COPY requirements.txt . # Upgrade pip RUN pip install --upgrade pip # Install the Python dependencies RUN pip install --no-cache-dir -r requirements.txt # Copy the project files COPY . . ENV PYTHONDONTWRITEBYTECODE=true # Export QT specific settings ENV QT_DEBUG_PLUGINS=1 ENV QT_QPA_PLATFORM=offscreen ENV QTWEBENGINE_DISABLE_SANDBOX=1 RUN pip install . # Expose the port the application runs on EXPOSE 8000 CMD ["coverage", "run", "-m", "pytest"]

    so adding ENV QTWEBENGINE_DISABLE_SANDBOX=1 fixed everything.

  • 0 Votes
    1 Posts
    204 Views
    No one has replied
  • 0 Votes
    3 Posts
    1k Views
    L

    @jeremy_k

    Thank You for the explanation!

    As you said I had to implement the roleNames() Function and adjusted the data().

    The code below now works

    import sys import typing import PySide6 from PySide6 import QtCore from PySide6 import QtGui from PySide6.QtCore import QByteArray class ProductListModel (QtCore.QAbstractListModel): def __init__(self, products, parent = None): super().__init__(parent) self.products = products def data(self, index, role): """Returns an appropriate value for the requested data. If the view requests an invalid index, an invalid variant is returned. Any valid index that corresponds to a string in the list causes that string to be returned.""" row = index.row() if not index.isValid() or row >= len(self.products): return None product = self.products[row] if role == QtCore.Qt.DisplayRole: return product.name elif role == QtCore.Qt.EditRole: return product.name elif role == QtCore.Qt.UserRole + 1: return product.id elif role == QtCore.Qt.UserRole + 2: return product.name return None def headerData(self, section, orientation, role=QtCore.Qt.DisplayRole): """Returns the appropriate header string depending on the orientation of the header and the section. If anything other than the display role is requested, we return an invalid variant.""" if role != QtCore.Qt.DisplayRole: return None if orientation == QtCore.Qt.Horizontal: return f"Column {section}" return f"Row {section}" def rowCount(self, parent: typing.Union[PySide6.QtCore.QModelIndex, PySide6.QtCore.QPersistentModelIndex] = ...) -> int: # return length of productList return len(self.products) def roleNames(self): roles = { QtCore.Qt.UserRole + 1: b'id', QtCore.Qt.UserRole + 2: b'name', } return roles class Product: def __init__(self, id:int, name:str): self.id = id self.name = name```
  • 0 Votes
    3 Posts
    357 Views
    A

    @dynobo Starting a reply with " I am in same boat" is a cliche and it does not help (you) .
    I have half a dozen "objects" passing messages - both directions and using "emit" and "connect".

    I am using GUI / tab to keep track and of course QDebug.
    It is not ideal ....

    I was going to add old fashioned flowchart ( text or GUI ) , but got sidetracked....

  • 0 Votes
    3 Posts
    415 Views
    EmrecpE

    @SGaist Thanks problem solved! (PySide6 updated to 6.3.1)

  • 0 Votes
    11 Posts
    768 Views
    SGaistS

    The smoothing done for the antialiasing will not be the same for all colors.

  • 0 Votes
    1 Posts
    436 Views
    No one has replied
  • 0 Votes
    1 Posts
    2k Views
    No one has replied
  • 0 Votes
    8 Posts
    1k Views
    SGaistS

    Great !

    Since you have it working now, please mark the thread as solved using the "Topic Tools" button or the three dotted menu beside the answer you deem correct so that other forum users may know a solution has been found :-)

  • 0 Votes
    1 Posts
    328 Views
    No one has replied
  • 0 Votes
    3 Posts
    779 Views
    W

    Well, I guess I'll have to wait for Qt 6.1 or compile it myself ;/

  • QML var property created from by python class

    Unsolved Qt 6
    1
    0 Votes
    1 Posts
    273 Views
    No one has replied
  • 2 Votes
    2 Posts
    5k Views
    JKSHJ

    @gd2shoe Thank you for this detailed, comprehensive, and correct post!

    As far as I can see, everything you've written is correct. I can't see anything important that you've left out.

    the Qt "main thread" is the first thread to create a QObject instance.

    ...

    Only one QCoreApplication instance can be created at a time (or it's derivatives). It should be created in the Qt "main thread" (which should also be its thread affinity). Its exec() function starts the main event loop, and should be run from the Qt "main thread".

    Bingo. These are the core points from which everything else derives from.

    There is one more implication: If we want to destroy the QCoreApplication and create another one (without unloading the libraries from the process' memory), then we must keep the original "main thread" alive and create the new QCoreApplication in that same thread. Shutting down the original "main thread" means that we cannot create any more QCoreApplications in this process instance.

    Currently, the formal documentation is incomplete, and somewhat inaccurate/misleading. Hopefully that will be rectified at some point.

    Would you like to have a go at correcting it? (Both the documentation and the runtime warning, "WARNING: QApplication was not created in the main() thread.")

  • 0 Votes
    4 Posts
    2k Views
    Cr0ssC

    Hi @SGaist, I took you advice and finally found out where the problem is.
    I looked into Wependency Walker and realized that I can import PySide6.QWidgets before I import wiggly, So that the dlls needed is already loaded for wiggly.
    I've been testing wiggly using one single import wiggly in IPython, not runing the main.py directly in the examples, trying to copy dlls from one place to another, and kept getting ImportErrors.
    Now I write:

    import PySide6.QtWidget import wiggly

    and it works.

    Thanks for your help!

  • 0 Votes
    3 Posts
    2k Views
    T

    @JonB
    Thanks for pointing that out, I completely missed it.
    I'll go with PySide2 until more features are released in Qt6 like you mentioned.

    Thanks again.