pyqt4

Multiple drag and drop in PyQt4

Hi, i can't find an example on dragging (and dropping) multiple elements with Qt/PyQt; In my case i need to drag elements from this QTableView: class DragTable(QTableView): def __init__(self, parent = None): super(DragTable, self).__init__(parent) self.setDragEnabled(True) def dragEnterEvent(self, event): ...

Cannot select item from QListView with custom QStyledItemDelegate

I want to render each row with HTML code. The rendering works but -at least for me- items cannot be selected individually. import sys from PyQt4.QtCore import * from PyQt4.QtGui import * #################################################################### def main(): app = QApplication(sys.argv) w = MyWindow() w.show(...

How to optimize PyQt QSortFilterProxyModel filter reimplementation?

I have a reimplemented QSortFilterProxyModel acceptRows to achieve custom behavior, i want it to not filter out items which have a valid child. class KSortFilterProxyModel(QSortFilterProxyModel): #FIXME: Funciona pero es endemoniadamente lento def __init__(self, parent=None): super(KSortFilterProxyModel, self).__init__(parent) s...

PyQt4 tray icon application context menu items don't work.

Hello! I've got a simple tray icon application, but "About" context menu item doesn't work at all. I'm definitly mising something simple, but important here. The question is what should i fix to see "About" menu item working? import sys from PyQt4 import QtCore from PyQt4 import QtGui class SystemTrayIcon(QtGui.QSystemTrayIcon): ...

How to organize GUI Code (for PyQt)?

Hi, i am looking for something similar to http://stackoverflow.com/questions/836218/organizing-gui-code, but for Python and PyQt4. Especially, I am looking at tips and examples of how to handle and store the configuration data, general state etc. EDIT: I have found some hints regarding older versions under: http://www.commandprompt.co...

Dynamically adding checkboxes with PyQt4

I have a simple GUI built using python and PyQt4. After the user enters something into the program, the program should then add a certain number of checkboxes to the UI depending on what the user's input was. For testing purposes, I have one checkbox existing in the application from start, and that checkbox is nested inside of a QVBoxL...

PyQt4 Threading: Sending data back to a thread

I'm writing a program, with a PyQt frontend. To ensure that the UI doesn't freeze up, I use QThreads to emit signals back to the parent. Now, I have reached a point where I need my thread to stop running, emit a signal back to the parent, then wait on the parent to return an approval for the thread to continue (after the user interacts...

AttributeError: 'module' object has no attribute 'QtString'

Hi My development eviroment: os: windows xp python: python-3.1.2.msi pyqt: PyQt-Py3.1-gpl-4.7.4-1.exe code: import sys from PyQt4 import QtCore, QtGui app = QtGui.QApplication(sys.argv) s = QtCore.QtString() sys.exit(app.exec_()) It always show me in 'module' s = QtCore.QtString() Attribu...

how to force matplotlib to update a plot

I am trying to construct a little GUI that has a plot which updates every time a new data sample is read. I would prefer not to run it with a timer, since the data will be arriving at differing intervals. Instead, I'm trying to make an implementation using signals, where the data collection function will emit a signal when data is read...

PyQt QGraphicsView fails to setWindowIcon

I'm using sub-classed QGraphicsView's in an MDIArea I want to be able to change the icon of the window from 'within' the object, but it just seems to ignore me... no errors or warnings... it just doesn't do it. if self.world.is_dirty: self.setWindowIcon( QtGui.QIcon ( 'images/dirty.png' ) ) self.setWindowTitle('dirty') else: ...

QMainWindow with only QDockWidgets and no central widget

We have a window with several components in QDockWidgets. Ideally, we'd like to have all components dockable, but there is one component that will likely always be visible. So we made that the central widget. However, this does not allow us to create a tabbed stack of dockable widgets (as you can create by e.g. calling tabifyDockWidge...

How to implement MousePressEvent for a Qt-Designer Widget in PyQt

Hi, I've got a Widget (QTabeleWidget, QLabels and some QButtons). It was build in Qt-Designer. And now I have to implement some things. For that I need the mousePressEvent. Usually I would write a subclass and write something like this: def mousePressEvent(self, event): if event.button() == Qt.LeftButton: print "left"...

PyQt: Right to left controls

I need my all controls to be right aligned. so when resizing they should move with the right upped corner of window instead of left upper. In visual studio, I simply set the Anchor property of any control to right and up. but PyQt has no Anchor or Dock property. Setting layoutDirection to RightToLeft didn't help. note: I'm trying to lea...

Clear a TableView in PyQt

Hello there, I'm in the process of learning how to display data and tables using PyQt. Ultimately I'd like to have a Table showing the contents of a database, but for now I'm just getting to grips with some of the fundamentals. I have a basic setup (pasted below) made using Qt Designer with a set of buttons ("Create", "Add Row", "Add Co...

restrict movable area of qgraphicsitem

Is there a way to restrict the area where a QGraphicsItem like QRect can be moved when setFlag(ItemIsMovable) is set? I'm new to pyqt and trying to find a way to move an item with the mouse, and the restrict it to only vertically/horizontally. Thanks! ...

Partially editable PyQt4 TextEdit

I'm currently making a frontend for my favorite expression-oriented arbitrary-precision calculator using PyQt4. The problem with it is that there doesn't seem to be any way to make part of a TextEdit widget read-only (specifically, the text that has already been sent and the results thereof) but the rest of it fully editable. Do I need t...

PyQt4 rich text editor WYSIWYG toolbar to set basic text properties

I'm using PyQT4 to create a little GUI that allows people in my lab to write notes about physiological experiments. Right now I've got plain text editing going but it would be nice if the user could use rich text editing to set the currently selected text's font properties, bold/italic/font/font size would be sufficient. I am specificall...

Displaying QComboBox text rather than index value in QStyledItemDelegate

So I have a model and one of the columns contains a country. However because I want to display a combo box to choose the country from a list of options, I don't store the country name in the model directly. Instead I store an index value into a list of allowable countries. This allows me to use a QComboBox in my form view as recommended ...

Pluggable Python program

I want to make a PyQt4 program that supports plugins. Basically I want the user to be able to write QWidget subclasses in PyQt4 and add/remove them from the main application window via a GUI. How would I do that, especially the plugin mechanism? ...

Is it possible to scale the content of a QVBoxLayout in pyqt4?

Hi all, couldn't find anything with google or search. I have some QPushButtons and QLabels in a QVBoxLayout. Now I want them to scale down. Not only the text, the hole QButton and QLabel. Is that possible? If yes, can you please tell me how or post me a link to the doc. I'm pretty sure, that there must be a way. But I think I'm search...