Skip to content

Qt for Python

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

3.3k Topics 14.6k Posts
  • how to set the color of row numer that is diffrent with table header?

    Unsolved
    2
    0 Votes
    2 Posts
    167 Views
    JonBJ
    @Harning Hello and welcome. Your question is unclear: what does "diffrent with table header" mean? If you have a model, and you are using, say, a QTableView to display it, one way is to use QVariant QAbstractItemModel::data(const QModelIndex &index, int role = Qt::DisplayRole) const where for role == Qt::ForegroundRole or perhaps Qt::BackgroundRole you make it return the desired color. If the color varies by row number you can look at the passed in index.row() to determine which color to return.
  • show() and exec_() behavior difference

    Unsolved
    7
    0 Votes
    7 Posts
    5k Views
    RokeJulianLockhartR
    @Junhi, if __name__ == "__main__": prevents invocation as module, instead only as script.
  • QTabWidget: having currentChanged() signal at drop time, not a drag time

    Unsolved
    1
    0 Votes
    1 Posts
    141 Views
    No one has replied
  • Artifacts when using a QPixmap

    Unsolved
    4
    0 Votes
    4 Posts
    425 Views
    JonBJ
    @LorDawid QPixmap::fill() is probably an "expensive" operation (pixmap could be "large"), and also a waste if you then do your own fill or set your own pixmap, so that is presumably why they leave it uninitialized.
  • This topic is deleted!

    Unsolved
    3
    0 Votes
    3 Posts
    26 Views
  • PySide2 - missing QOpenGLShader

    Unsolved
    2
    0 Votes
    2 Posts
    746 Views
    F
    PLease use the current version 6.5; PySide2 does not support this. See https://doc.qt.io/qtforpython-6/gettingstarted/index.html .
  • problem to set the colour of the 0 column

    Unsolved
    2
    0 Votes
    2 Posts
    232 Views
    jsulmJ
    @FaTr You do not set any items in column 0 as far as I can see (so item(r, 0) returns None), that is why you get this error.
  • Make complete python script from Qt Designer

    Unsolved
    4
    0 Votes
    4 Posts
    3k Views
    JonBJ
    @pascor When I did Python-Qt stuff a few years ago I used PyCharm as my IDE. Which I found very good. Certainly if you did elect to use the pyuic/pyside6-uic route of processing the .ui file to produce a source file --- which the C++ build has to do --- rather than the run-time QUiLoader::load() you got invaluable development-time support like auto-completion of member variables etc. etc. It is true that the hassle of having to run pyuic each time after changing the .ui file was a minor irritant, but worth it for the other benefits one gained. I don't know what the editing/debugging experience for PySide inside Qt Creator is these days, but probably poor? There was no support at all in my time. Does it have an integrated Python debugger with your source code when you run? If not I would use PyCharm.
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    1 Views
    No one has replied
  • Gyroscope with python

    Unsolved
    2
    0 Votes
    2 Posts
    231 Views
    JonBJ
    @Nergui Not sure what help you are expecting. You have to draw a gyroscope and you have to connect to the sensor inn code through whatever API it offers.
  • This topic is deleted!

    Unsolved
    16
    0 Votes
    16 Posts
    131 Views
  • QPrinter

    Unsolved
    7
    0 Votes
    7 Posts
    480 Views
    SGaistS
    I understood that you have to style the output, hence my answer. It's not the printer that does that part, it's the word processing application. A printer receives a set of instructions on how to print things, you can alter the color, the number of page per sheet and that kind of stuff in the printer settings. However, you cannot tell your printer that it has to use an interline space of 5. What you are currently asking for refers to what is called rich text. Hence my suggestions about loading your text file in a QTextDocument and then apply the styling you need, and then print that document.
  • Example sought: Before and after image slider

    Unsolved
    4
    0 Votes
    4 Posts
    519 Views
    SGaistS
    Hi, So you would need something like a QSplitter but with two widgets on top of each other rather than beside ?
  • Example sought: overlapping images

    Solved
    3
    0 Votes
    3 Posts
    971 Views
    C
    RESOLVED: In order to compose the desired stack image I needed to use a QPainter. My logic was roughly: baseImage = QtGui.QImage("<path to base image>") stackSize = 3 stackImageSize = QtCore.QSize(baseImage.width(), baseImage.height() * stackSize) stack = QtGui.QImage(size, QtGui.QImage.Format.Format_ARGB32) stack.fill(QtGui.QColor(0, 0, 0, 0)) painter = QtGui.QPainter() painter.begin(stack) for i in range(count): adjust = baseImageHeight * i + baseImageHeight - 6 * i painter.drawImage(0, size.height() - adjust, unselected) painter.end() label = QtWidgets.QLabel() label.setFixedHeight(size.height()) label.setFixedWidth(size.width()) label.setPixmap(QtGui.QPixmap.fromImage(stack)) layout = QtWidgets.QVBoxLayout() layout.addWidget(label) self.setLayout(layout)
  • How to set up possible min and max float values with QDoubleValidator

    Unsolved
    4
    0 Votes
    4 Posts
    531 Views
    SGaistS
    If memory serves well, you can use the buttonSymbols property for that.
  • stretch layout inside QScrollArea which is inside another layout

    Solved
    2
    0 Votes
    2 Posts
    156 Views
    O
    I found the solution by setting the widget resizeble by using scroll_1.setWidgetResizable(True)
  • Drag and Drop adding the QUrl as well as the file path in QLineEdit

    Solved
    3
    0 Votes
    3 Posts
    2k Views
    A
    @friedemannkleint Yes! Thank you! That allowed me to see that it was the "text/uri-list" data it was inserting. I ended up re-defining the Drop function for the QLineEdit class and that seemed to have done the trick! class FileDropLineEdit(QLineEdit): def __init__(self, parent=None): super().__init__(parent) def dropEvent(self, event): if event.mimeData().hasUrls(): file_path = event.mimeData().urls()[0].toLocalFile() file_path = file_path.replace("/", "\\") self.setText(file_path) event.acceptProposedAction() else: event.ignore() Since it's now its own class, I also removed the reference to the Drop event in my event filter and referenced it when creating the initial window.
  • matplotlib fails because of incomplatible qt versions

    Moved Solved
    21
    0 Votes
    21 Posts
    4k Views
    D
    The bug disappeared after qt upgrade to the version 5.15.9
  • PySide 6.5.0: Cannot load library qtquick2plugin.dll

    Unsolved qt for python pyside
    4
    0 Votes
    4 Posts
    1k Views
    D
    @friedemannkleint I tried all that, I tried different versions of virtual environments. Finally I switched over to PyQt6 and now it works flawlessly.
  • QPlainTextEdit for very large files 4+ GB.

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