Skip to content

Qt for Python

For discussion and questions about Qt for Python (PySide & Shiboken)

3.3k Topics 14.6k Posts
  • This topic is deleted!

    Unsolved 31 Dec 2020, 11:54
    0 Votes
    1 Posts
    11 Views
    No one has replied
  • Change The Text Of QChart's Legend and It's Width

    Unsolved 30 Dec 2020, 12:49
    0 Votes
    2 Posts
    652 Views
    @Qt-Bot05 For the PyCharm warning, it does depend on your exact code but chances are this is a spurious warning, which you can ignore. There are several hits from Googling: pycharm Parameter unfulfilled. BTW, I forget where but somewhere in PyCharm settings there is a checkbox/selection for "I am using PyQt or PySide2". If you have not already set that, it might perform better on PyQt/PySide2 issues like this.
  • 0 Votes
    3 Posts
    1k Views
    @Sdutt I am also new to Qt, I began a new project just this week using qt6 / PySide6. If you use Qt Creator, many of its default project templates are geared towards creating a Qt Widget app, with perhaps some form.ui that can be designed in Qt Designer. I wanted to use QtQuick / QML right from the start and rely on it entirely for my project. Qt Design Studio is perfect for my needs there, I just want to use it to iterate on the interface, and it has just enough python support (you can specify a path to an executable in a virtualenv and it also supports the python language server protocol) to be useful. It can be used to edit any qml file, but it most often expects you to use its design view on ui.qml files. I picked up a book called 'Getting started with QtQuick' by Paolo Sereno on Kindle. I haven't quite figured out how to get my project to run on windows yet, but it works fine on linux, so I suspect there is some environmental issue at play there. Here's a link to the project: https://github.com/awillis/sozu-tmt Hope this helps you figure out what you need.
  • Qt 6 and Python?

    Unsolved 9 Dec 2020, 16:39
    0 Votes
    5 Posts
    1k Views
    @Franky123 I tried PySide6 and it actually works :)
  • 0 Votes
    2 Posts
    353 Views
    @Frime said in Using PySide within a python plugin in a non-Qt environment: Do I need to start an extra thread for the app.exec_() call? exec() blocks the calling thread permanently until you shut down Qt. I'm not familiar with how Octoprint loads and runs plugins. But if it runs your plugin script in the same thread as the core program, then yes you need to create an extra thread to call exec() and all other Qt GUI functions.
  • This topic is deleted!

    Unsolved 29 Dec 2020, 09:17
    0 Votes
    1 Posts
    1 Views
    No one has replied
  • Basic QQmlApplicationEngine in PySide6

    Solved 28 Dec 2020, 03:28
    0 Votes
    12 Posts
    2k Views
    @eyllanesc Thanks so much! On a lark I decided to try running this on my linux machine, and it worked just fine. I will try using qmlscene on my windows machine to find the errors there. I opened this thread to ensure that I was using QQmlApplicationEngine correctly, this issue is resolved. Thanks again :)
  • I can't style my widgets

    Solved qt for python python 22 Dec 2020, 03:51
    0 Votes
    13 Posts
    2k Views
    @JKSH Thanks !!!
  • I need a widget suggestion.

    Solved 28 Dec 2020, 20:32
    0 Votes
    3 Posts
    354 Views
    @SGaist Thank you, that's exactly what I wanted.
  • Qtablewidget display

    Unsolved 27 Dec 2020, 19:33
    0 Votes
    7 Posts
    936 Views
    @SGaist i start doing with sqlite3, so i continue with it
  • 0 Votes
    2 Posts
    268 Views
    Hi and welcome to devnet, Please use proper coding tags otherwise it makes you post unreadable. You should also explain what exactly is your issue, what you tried, what you got, etc. Throwing that many code without any explanation does not motivate people to take a look at your problem.
  • Error of installation

    Unsolved 27 Dec 2020, 10:07
    0 Votes
    3 Posts
    637 Views
    I think I will use wayland. But what can I do ?
  • 0 Votes
    2 Posts
    452 Views
    @YassineKira Your question seems to have nothing to do with the question title of "multiple values". Unless you mean values which are the result of multiplication, which is a different thing! QTableWidget is a wrapper around QTableView. It has its own model built-in, but that is hidden from you so you cannot override anything in it. Consequently you will have to use setData() (or setItem()) to explicitly set the desired result in column #3, and if you allow editing of the other columns you will have to set a slot to recalculate whenever those change. If you change over to using a QTableView instead you can define your own model. And that way, with subclassing, you can override the data() method so that it always calculates the product, instead of having to call setData(). That's how I would do it. We expect people to implement the code for suggestions themselves, not to have to write lines of code for everyone's questions. Still less if you expect a Python sample only. That's what programming is about. If you want to follow the example in the reference you quoted just translate the few lines of C++ into Python, it;s not hard.
  • This topic is deleted!

    Unsolved 26 Dec 2020, 20:13
    0 Votes
    1 Posts
    1 Views
    No one has replied
  • 0 Votes
    10 Posts
    3k Views
    You should not access GUI elements from other threads than the main thread.
  • 0 Votes
    10 Posts
    3k Views
    Thanks @JonB for your thoughtful answer. It gave me more insight on the logic of lessThan(). I'll give this a big try and see where I'll get. Wish you a good day !
  • mouse movement as arrows up/down/left/right

    Unsolved 22 Dec 2020, 10:28
    0 Votes
    3 Posts
    590 Views
    Thanks, you had right. Needed to do something like that, but I didn't know how to do it. I tried QGestures which was my first choise, but I didn't find any information for pyqt and I didn't manage to make it work either. Finally I found moosegestrures library which does more that I want, but again no much info about that. It has some pygame examples though, and with those I managed to do what I wanted(probably not with an elegant way). So here is how I did it: class MainWindow(QMainWindow, Ui_MainWindow): def __init__(self, parent=None): super(MainWindow,self).__init__(parent) self.old_x = QCursor.pos().x() self.old_y = QCursor.pos().y() self.setupUi(self) self.frame.setMouseTracking(True) self.frame.installEventFilter(self) self.points[] .... def eventFilter(self, source, event): if event.type() == QtCore.QEvent.MouseMove: #if event.buttons() == QtCore.Qt.NoButton: # print("Simple mouse motion") if event.buttons() == QtCore.Qt.LeftButton: if len(self.points) > 2: startx, starty = self.points[0][0], self.points[0][1] for i in range(len(self.points)): self.points[i] = (self.points[i][0] - startx, self.points[i][1] - starty) self.points.append((event.localPos().x(), event.localPos().y())) print(self.points) #self.points = [] elif event.type() == QtCore.QEvent.MouseButtonRelease: if event.button() == QtCore.Qt.LeftButton: print("Released!") self.mouseDown = False strokes = moosegesture.getGesture(self.points) strokeText=str(strokes[-1]) #print(strokeText) if strokeText == "R": self.matrix, done = logic.right(self.matrix) if done: self.stateCheck() if strokeText == "L": self.matrix, done = logic.left(self.matrix) if done: self.stateCheck() if strokeText == "U": self.matrix, done = logic.up(self.matrix) if done: self.stateCheck() if strokeText == "D": self.matrix, done = logic.down(self.matrix) if done: self.stateCheck() return self.frame.eventFilter(source, event)
  • 0 Votes
    8 Posts
    2k Views
    @anoop1 As I said, how do you expect Python's Cmd.cmdloop to interact with Qt's event-driven system and windows/widgets?
  • QMovie displays GIF with delay.

    Unsolved 21 Dec 2020, 19:25
    0 Votes
    8 Posts
    1k Views
    That won't change anything if you are blocking the event loop be it with widgets or QtQuick, you'll have similar issue. I highly recommend to fix the blocking parts so you can more freely change the GUI stack if you really want to.
  • Threading don't creating buttons in frame

    Solved 21 Dec 2020, 23:09
    0 Votes
    11 Posts
    1k Views
    @Black-Cat See this example https://stackoverflow.com/questions/50413628/using-qlineedit-settext-freezes-the-window-but-background-tasks-works-fine/50415394#50415394