pyside

How can I find a substring and highlight it in QTextEdit?

人走茶凉 提交于 2019-11-30 16:04:04
I have a QTextEdit window that shows the content of a file. I would like to be able to find all matches inside the text using a regex and highlight them either by making the match background different or by changing the match text color or making it bold. How can I do this? I think the simplest solution to your problem is to use the cursor associated to your editor in order to do the formatting. This way you can set the foreground, the background, the font style... The following example marks the matches with a different background. from PyQt4 import QtGui from PyQt4 import QtCore class

Displaying a video stream in QLabel with PySide

久未见 提交于 2019-11-30 15:48:52
问题 Can anybody point me in the right direction on how to create a new QMovie "provider" in PySide? I have a video stream that I want to display as simply as possible (no audio, just a sequence of frames with an unknown and variable framerate). This example seems perfect except that my video is coming from an unconventional source. It's not a file but a network stream in a format that is not standardized. I can easily write code that receives each frame and my idea is to create a "QMovie provider

Qt Widget with Transparent Background

烈酒焚心 提交于 2019-11-30 15:33:43
(I'm using PySide, but I think the answer would be the same/similar for any language bindings). I'm trying to take the shaped clock example, located here , and cause the face of the clock (circle) to be transparent so that all I see are the clock hands and minute ticks. As is, when the example runs, it looks like this . I'm using Windows 7. So far, I've tried the following (in the constructor): self.setAttribute(QtCore.Qt.WA_TranslucentBackground) Clock appears (has presence in task bar), but I can't see it anywhere self.setAttribute(QtCore.Qt.WA_NoSystemBackground) Clock appears, but has

pyqt QTablewidget remove scrollbar to show full table

纵然是瞬间 提交于 2019-11-30 14:43:36
I have a scrollview to which I dynamically add QTableWidgets. However, the QTables themselves also have scrollbars and therefore dont show the full table. Is there a way to disable the scroll bar so that the table always gets shown in full? EDIT: I added self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) as suggested. The scroll bar does disappear, but it still only shows the partial tables (Ican scroll with hovering iverthe table and using the mouse wheel, still). The code for the Widget is below from PySide.QtGui import * from

Edit table in pyqt using QAbstractTableModel

孤街浪徒 提交于 2019-11-30 14:01:00
I'm trying to create an editable table in PyQt. Here's the code for just displaying the table: import sys from PyQt4 import QtGui, QtCore from PyQt4.QtCore import * from PyQt4.QtGui import * # données à représenter my_array = [['00','01','02'], ['10','11','12'], ['20','21','22']] def main(): app = QApplication(sys.argv) w = MyWindow() w.show() sys.exit(app.exec_()) # création de la vue et du conteneur class MyWindow(QWidget): def __init__(self, *args): QWidget.__init__(self, *args) tablemodel = MyTableModel(my_array, self) tableview = QTableView() tableview.setModel(tablemodel) layout =

PySide Signal argument can't be retrieved from QML

两盒软妹~` 提交于 2019-11-30 09:23:52
问题 I've noticed that QML can receive a signal emitted from Python by using the Connections object. Unfortunately, I can't figure out how to get that object to receive the arguments of that signal. I've created a minimal test case that demonstrates what I want to do: min.py from PySide import QtCore, QtGui, QtDeclarative import sys # init Qt app = QtGui.QApplication(sys.argv) # set up the signal class Signaller(QtCore.QObject): emitted = QtCore.Signal(str) signaller = Signaller() # Load the QML

A .py file which compiled from .qrc file( using pyside-rcc ) does not work

徘徊边缘 提交于 2019-11-30 09:18:49
问题 I am working on python project and I have a problem with my .py file which complied from .qrc file. First, let I explain briefly about my project. I created my project GUI in QtDesigner and also use the image in the GUI. Then, I generate .py from .ui file using pyside-uic and generate .py file from .qrc file using pyside-rcc. The problem is when I use the .py file (an image file), images does not show in my GUI. Is anybody knows how to solve this problem? Thank you for all your answer. :) Ps.

PySide Qt: Auto vertical growth for TextEdit Widget, and spacing between widgets in a vertical layout

时光毁灭记忆、已成空白 提交于 2019-11-30 09:08:31
I need to Solve two problems With my widget above. I'd like to be able to define the amount of space put between the post widgets shown in the image (they look fine as is, but I wanna know it's done). I'd like to grow the text edits vertically based on the amount of text they contain without growing horizontally. For 1 the code that populates the widgets is as follows : self._body_frame = QWidget() self._body_frame.setMinimumWidth(750) self._body_layout = QVBoxLayout() self._body_layout.setSpacing(0) self._post_widgets = [] for i in range(self._posts_per_page): pw = PostWidget() self._post

How to get all child components of QWidget in pyside/pyqt/qt?

假装没事ソ 提交于 2019-11-30 09:07:48
I am developing a desktop application using pyside(qt), I want to access(iterate) all line edit components of QWidget. In qt I found two methods findChild and findChildren but there is no proper example found and My code shows error, 'form' object has no attribute 'findChild'. Here 'form' is Qwidget form consist components lineEdit, comboboxes, Qpushbuttons etc. Code: lineEdits = form.findChild<QLineEdit>() //This is not working lineEdits = form.findChild('QLineEdit) //This also not working The signatures of findChild and findChildren are different in PySide/PyQt4 because there is no real

How to create a proxy model that would flatten nodes of a QAbstractItemModel into a list in PySide?

怎甘沉沦 提交于 2019-11-30 08:59:47
问题 I have a hierarchy of nodes represented by a custom QAbstractItemModel. Is it possible to create a proxy model that would flatten the hierarchy into a list to allow me to present all the nodes/items in a QListView (without a proxy only the first level of the tree gets presented)? A A +---1 1 2 2 +--3 3 4 => 4 B B +---5 5 6 6 +--7 7 8 8 Thanks, FipS 回答1: It's way easier to just coerce a QTreeView to look like a list view: view = QtGui.QTreeView() view.setModel(model) view.expandAll() view