Skip to content

Language Bindings

You're using Qt with other languages than C++, eh? Post here!
858 Topics 3.4k Posts
  • Camera Example Error

    Solved
    2
    0 Votes
    2 Posts
    616 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
    465 Views
    SGaistS

    Hi and welcome to devnet,

    QTextCodec comes to mind for that task.

  • 0 Votes
    4 Posts
    791 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
    3
    0 Votes
    3 Posts
    685 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
    585 Views
    No one has replied
  • how do i separate these sudoku boxes (grids)

    Unsolved
    4
    0 Votes
    4 Posts
    720 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
    735 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
    474 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
    S

    @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
    3k 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
  • 0 Votes
    1 Posts
    491 Views
    No one has replied
  • QPushButton binding does not work without lambda keyword

    Unsolved
    5
    0 Votes
    5 Posts
    767 Views
    SGaistS

    Can you rather post a minimal example that shows that behaviour ?

  • Problem with SetIcon when using a png

    Unsolved
    7
    0 Votes
    7 Posts
    942 Views
    SGaistS

    Because the environment variable is described here. The fact that you are using python is of no importance here.

  • glitch in javascript bindings

    Unsolved
    7
    0 Votes
    7 Posts
    1k Views
    Gojir4G

    @skylendar Sorry, I miss your last message.
    Any improvements here ?

  • Golang TreeView example not working

    Unsolved
    2
    0 Votes
    2 Posts
    924 Views
    mrjjM

    Hi and welcome to the forums
    I dont know Golang but the interface is the same so i would
    check in func (m *CustomTableModel) data
    that this test
    if role != int(core.Qt__DisplayRole) {
    return core.NewQVariant()
    }

    is not always returning an empty variant for each call.

    also
    case 0:
    return core.NewQVariant12(item.firstName)
    case 1:
    return core.NewQVariant12(item.lastName)

    does return a valid QVariant ?

    i wondered why the empty one is
    NewQVariant()
    but with data its NewQVariant12 ?

  • Which is Better C or C++?

    Unsolved
    5
    0 Votes
    5 Posts
    1k Views
    JonBJ

    @Mayankjain
    C is plain better (IMHO) :) But for your career, C++ is definitely more advisable!

  • QAxServer in Python [PySide] [PyQt]

    2
    0 Votes
    2 Posts
    2k Views
    F

    Hello,

    I'm facing the same issue.

    Have you solved this problem?

  • Q_Property add range macros

    Unsolved
    2
    0 Votes
    2 Posts
    642 Views
    SGaistS

    Hi,

    AFAIK, there's none. You need to implement your own macro on top Q_PROPERTY to do that.