Skip to content

Language Bindings

You're using Qt with other languages than C++, eh? Post here!
865 Topics 3.4k Posts
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    10 Views
    No one has replied
  • 0 Votes
    6 Posts
    2k Views
    SGaistS
    Thanks for the links !
  • PySide2 - Serial communication QSerialPort or pyserial

    Unsolved
    7
    0 Votes
    7 Posts
    5k Views
    A
    I am preparing a patch to support QSerialPort in PySide2 here: https://codereview.qt-project.org/c/pyside/pyside-setup/+/299976
  • QtJambi 5.12.8 is nearly alive!

    Solved
    4
    2 Votes
    4 Posts
    891 Views
    SGaistS
    Great ! Since you have it alive now please mark the thread as solved using the "Topic Tools" button so that other forum users may know a solution has been found.
  • add delay in python

    Unsolved
    5
    0 Votes
    5 Posts
    4k Views
    W
    Sleep() function actually suspends the processing of the thread in which it is called by the operating system, allowing other threads and processes to execute while it sleeps. With multiple threads and processes, sleep() suspends your thread - it uses next to zero processing power.
  • Communicating between Qt c++ program and another Python Qt program

    Unsolved
    5
    0 Votes
    5 Posts
    2k Views
    AdantehA
    @SGaist Unfortunately I am locked into Qt4 with the program itself. Heck, I was even hoping I could somehow influence this Qt4 app by some external python app running Pyside2. I have no idea how any of the underlying Qt infrastructure works, but that seems very far from possible (at least for me) My experience with PyQt5 and Pyside2 has been super pleasant and I feel really comfortable in Python, and not comfortable at all in C++, so that's why I'm looking around if there's an alternative. Ill probably give this a go for starters: https://ubuverse.com/embedding-the-python-interpreter-in-a-qt-application/
  • QByteArray to string?

    Solved python3 pyqt5
    29
    -1 Votes
    29 Posts
    34k Views
    JonBJ
    @germyrinn Hi, this was an old post of mine. As I wrote, the problem is that for the £ sign e.g. read from a file created in the way I describe, decode("utf-8") gives me a UnicodeDecodeError. I found the only conversion which works is decode("cp850").
  • How to set file name according to current system language in windows

    Unsolved
    11
    0 Votes
    11 Posts
    2k Views
    JonBJ
    @SGaist OIC. So how to change the file name from German to English or vice-versa The OP does not really mean change the filename (on disk)? Then there is no issue.
  • Camera Example Error

    Solved
    2
    0 Votes
    2 Posts
    714 Views
    N
    @Nick79 I resolved it. On my linux machine I had to install some gstreamer packages. Now everything works! Great
  • iso 646de

    Unsolved
    2
    0 Votes
    2 Posts
    564 Views
    SGaistS
    Hi and welcome to devnet, QTextCodec comes to mind for that task.
  • PySide2: Understanding QGraphicsItemGroup.setScale()

    Unsolved pyside2 qgraphicsscene scale
    4
    0 Votes
    4 Posts
    1k Views
    Gojir4G
    @galou_breizh I answered in the other post. But it's not a good way to duplicate post for the same issue. Please try to avoid it in the future, thanks
  • PySide2: Filling not scaled

    Unsolved pyside2 qgraphicsscene scale
    3
    0 Votes
    3 Posts
    879 Views
    Gojir4G
    @galou_breizh I think point_size is too small and the ellipse generated is "pixelated" because of that. This gives a nice circle filled with blue # -*- coding: utf-8 -*- """Show an incomprehension in setScale for QGraphicsItemGroup.""" from PySide2 import QtCore from PySide2 import QtGui from PySide2 import QtWidgets point_size = 10.0 # In real-world units. # Get entrypoint through which we control underlying Qt framework app = QtWidgets.QApplication([]) scene = QtWidgets.QGraphicsScene() group = QtWidgets.QGraphicsItemGroup() scale = 50.0 # 1 real-world units = 500 px. !! Has no apparent effect. pen = QtGui.QPen(QtCore.Qt.red) brush = QtGui.QBrush(QtCore.Qt.blue) x = 1.0 # Real-world units. y = 2.0 # Real-world units. top_left = (x - point_size / 2.0, y - point_size / 2.0) ellipse = QtWidgets.QGraphicsEllipseItem( QtCore.QRectF(*top_left, point_size, point_size)) ellipse.setPen(pen) ellipse.setBrush(brush) ellipse.setScale(scale) group.addToGroup(ellipse) # group.setScale(scale) scene.addItem(group) view = QtWidgets.QGraphicsView(scene) view.show() # Start Qt/PySide2 application. If we don't show any windows, the # app would just loop at this point without the means to exit app.exec_()
  • Experiences with QtSharp and Qml.Net

    Unsolved
    1
    0 Votes
    1 Posts
    659 Views
    No one has replied
  • how do i separate these sudoku boxes (grids)

    Unsolved
    4
    0 Votes
    4 Posts
    845 Views
    jazzycamelJ
    @nullbuil7 said in how do i separate these sudoku boxes (grids): import sys from PySide2.QtWidgets import * from PySide2.QtGui import * class SudokuGrid(QWidget): def init(self): super(SudokuGrid, self).init() self.initGUI() def initGUI(self): self.setWindowTitle("Sudoku Grid Example") self.setGeometry(800, 800, 400, 350) self.setGrid() def setGrid(self): gridLayout = QGridLayout() box1 = QGridLayout() box2 = QGridLayout() box3 = QGridLayout() box4 = QGridLayout() box5 = QGridLayout() box6 = QGridLayout() box7 = QGridLayout() box8 = QGridLayout() box9 = QGridLayout() hline = QFrame() hline.setFrameShape(QFrame.HLine) hline.setFrameShadow(QFrame.Sunken) vline = QFrame() vline.setFrameShape(QFrame.VLine) vline.setFrameShadow(QFrame.Sunken) gridLayout.addLayout(box1,0,0) gridLayout.addWidget(vline, 0, 1) gridLayout.addLayout(box2,0,2) gridLayout.addWidget(vline, 0, 3) gridLayout.addLayout(box3,0,4) gridLayout.addWidget(hline, 1, 0, 1, 5) gridLayout.addLayout(box4,2,0) gridLayout.addWidget(vline, 2, 1) gridLayout.addLayout(box5,2,2) gridLayout.addWidget(vline, 2, 3) gridLayout.addLayout(box6,2,4) gridLayout.addWidget(hline, 3, 0, 1, 5) gridLayout.addLayout(box7,4,0) gridLayout.addWidget(vline, 4, 1) gridLayout.addLayout(box8,4,2) gridLayout.addWidget(vline, 4, 3) gridLayout.addLayout(box9,4,4) pos = [(0,0),(0,1),(0,2), (1,0),(1,1),(1,2), (2,0),(2,1),(2,2)] i = 0 while i < 9: box1.addWidget(QLabel("1", self), pos[i][0], pos[i][1]) box2.addWidget(QLabel("1", self), pos[i][0], pos[i][1]) box3.addWidget(QLabel("1", self), pos[i][0], pos[i][1]) box4.addWidget(QLabel("1", self), pos[i][0], pos[i][1]) box5.addWidget(QLabel("1", self), pos[i][0], pos[i][1]) box6.addWidget(QLabel("1", self), pos[i][0], pos[i][1]) box7.addWidget(QLabel("1", self), pos[i][0], pos[i][1]) box8.addWidget(QLabel("1", self), pos[i][0], pos[i][1]) box9.addWidget(QLabel("1", self), pos[i][0], pos[i][1]) i = i + 1 self.setLayout(gridLayout) if name == 'main': try: myApp = QApplication(sys.argv) myWindow = SudokuGrid() myWindow.show() myApp.exec_() sys.exit(0) except NameError: print("Name Error:", sys.exc_info()[1]) except SystemExit: print("Closing Window...") except Exception: print(sys.exc_info()[1]) Its not a bug in Qt or PySide2: you can't add a widget to a layout multiple times; you only create one each ofhline and vline and add them to multiple locations in your layout. See my example below where I create a new instance of hline and vline each time I use them (and tidied things up a bit): from PySide2.QtWidgets import QWidget, QGridLayout, QFrame, QLabel class SudokuGrid(QWidget): def __init__(self, parent=None, **kwargs): super().__init__(parent, **kwargs) self.setWindowTitle("Sudoku Grid Example") self.setGeometry(800,800,400,350) l=QGridLayout(self) boxes=[] for i in range(9): col=i%3 row=i//3 box=QGridLayout() boxes.append(box) l.addLayout(box, row*2, col*2) if col<2: vline=QFrame() vline.setFrameShape(QFrame.VLine) vline.setFrameShadow(QFrame.Sunken) l.addWidget(vline, row*2, (col*2)+1) if col==2 and row<2: hline=QFrame() hline.setFrameShape(QFrame.HLine) hline.setFrameShadow(QFrame.Sunken) l.addWidget(hline, (row*2)+1, 0, 1, 5) for box in boxes: for i in range(9): col=i%3 row=i//3 box.addWidget(QLabel(str(i),self), row, col) if __name__=="__main__": from sys import argv, exit from PyQt5.QtWidgets import QApplication a=QApplication(argv) s=SudokuGrid() s.show() exit(a.exec_()) I've tested this with PyQt5 not PySide2, but they are compatible and this code should work perfectly well. Hope this helps ;o)
  • setting style in python3/pyside2

    Solved
    2
    0 Votes
    2 Posts
    848 Views
    mrjjM
    Hi Should it not be on the application like ? QtGui.QApplication.setStyle(QtGui.QStyleFactory.create('Fusion'))
  • Attach Debugger to Valgrind PID

    Unsolved
    2
    0 Votes
    2 Posts
    1k Views
    R
    Relating to attaching Debugger to Valgrind PID, when I launch qtcreator ./qtcreator The following messages appear before launching Analyze->Valgrind Memory Analyzer with GDB Debug->Attach to Running Application QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root' QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root' QXcbShmImage: xcb_shm_attach() failed with error: 10 (BadAccess), sequence: 552, resource id: 311, major code: 130 (Unknown), minor code: 1
  • XML Request rejected

    Unsolved
    2
    0 Votes
    2 Posts
    553 Views
    SGaistS
    Hi, What version of Qt are you using ? What Linux distribution are you running ? What versions of OpenSSL do you have installed ? You are not connecting the error related signals anywhere, you should so you'll have more information about what is going wrong. On a side note, there's no need to create your QNetworkRequest on the the heap as shown in the QNetworkAccessManager documentation.
  • How to include the Lua library into my Qt project?

    Unsolved
    9
    0 Votes
    9 Posts
    3k Views
    ?
    @aha_1980 I will try compiling it myself since I'd like to stick with MinGW. Just tried that but MinGW outputs the following: 0 [main] sh 1816 sync_with_child: child 12536(0x1E4) died before initializing with status code 0xC0000142 208 [main] sh 1816 sync_with_child: *** child state waiting for longjmp /usr/bin/sh: fork: Resource temporarily unavailable mingw32-make: *** [Makefile:55: mingw] Error 128
  • how can i list the files in a directory

    Unsolved
    7
    0 Votes
    7 Posts
    4k Views
    JonBJ
    @Nathan-Miguel Look, the "dots" aren't part of a file name, they are the . and the .. entries in the directory, The other two are filenames. You are choosing to print them out all touching each other (testlist.join("")). Clearly that has nothing to do with your "want to set to open a file inside the folder". You can access indvidual files via each element in entryList() or entryInfoList(), as you please.
  • This topic is deleted!

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