pyqt

Qt uses CSS to color objects? Is there another way to go about this?

I am learning PyQt from this site. The tutorial is building a widget that colours a square. In this, they are using CSS to colour the square, rather than give it some sort of concrete property of colour. Why is this? Is there another way to do this without CSS or is this the preferred method? It seems awfully strange.. ...

Deep copy of a derived python object

I have an object in python that is derived from QtGui.QGraphicsPixmapItem with a few basic attributes and methods. After calling deepcopy on a reference to this object, I get an error saying that underlying C/C++ object has been deleted when I try to use the copy. I had received this error before, and it occured when I didn't call the ba...

PyQt ListView with groups

How can i create connection groups inside a QListView with PyQt. The group name should not be selectable. Example: http://www.shrani.si/f/T/bB/gSpSsYt/connectionlist.jpg :) ...

Create one keybord shortcut for 2 objects in PyQt

How can i create for "Ctrl+C" bindings for 2 objects: self.table, self.editor I have: shortcut = QtGui.QShortcut(QtGui.QKeySequence("Ctrl+C"), self.table, None, self.copyTable) shortcut2 = QtGui.QShortcut(QtGui.QKeySequence("Ctrl+C"), self.editor, None, self.copyText) This works, but is toogled. If i have focus on self.editor and for...

QSortFilterProxyModel returning artificial row

I'm using a QSortFilterProxyModel to filter results from a QAbstractListModel. However, I'd like to return a first entry which is not present in the original model, that is, it's somehow artificial. This is what I have so far: class ActivedAccountModel(QSortFilterProxyModel): ...

Getting Started with PyQt

I'm testing out some of the examples in Rapid GUI Programming with Python and Qt, but running into a stumbling block here or where. When I copied to following exercise (verbatim, from the book): import sys import time from PyQt4.QtCore import * from PyQt4.QtGui import * app = QApplication(sys.argv) try: due = QTime.currentTime() ...

PyQt_PyObject equivalent when using new-style signals/slots?

Hi. So I have a need to pass around a numpy array in my PyQt Application. I first tried using the new-style signals/slots, defining my signal with: newChunkToProcess = pyqtSignal(np.array()), however this gives the error: TypeError: Required argument 'object' (pos 1) not found I have worked out how to do this with the old-style signal...

PyQT: Rotate a QLabel so that it's positioned diagonally instead of horizontally

Hi folks, I'm working on a touch screen app where gui space is very tight. I'd like to rotate a QLabel a bit so that it's either vertical, or offset at a diagonal a bit. Any suggestions? I couldn't find anything relevant on the QLabel interface. Thanks so much! ...

Setting window style in PyQT/PySide?

I've been looking for how to do this and I've found places where the subject comes up, but none of the suggestions actually work for me, even though they seem to work out okay for the questioner (they don't even list what to import). I ran across self.setWindowFlags(Qt.FramelessWindowHint) but it doesn't seem to work regardless of the im...

PyQT: How do I handle loops in main?

I have an application that has a PyQT GUI. I set up the GUI in the usual PyQT fashion: app = QtGui.QApplication(sys.argv) win = MainWindow() win.initialize() win.show() sys.exit(app.exec_()) The problem is that right after this I have a while loop that handles signals (signal.signal(signal.SIGINT, ...) and also does some other things....

PyQT QtGui.QTableWidgetItem

I have a QtGui.QTableWidgetItem that I added to a table by the createRow function below: def createRow(self, listA): rowNum = self.table.rowCount() self.table.insertRow(rowNum) i = 0 for val in listA: self.table.setItem(rowNum, i, QtGui.QTableWidgetItem(val)) i += 1 Now I have a thread that will update ...

Right alignment for table cell in pyqt

I have QStandardItemModel and QTableView. I want to have the number align to the right. How can i specify this in pyqt? Now i have it like this (see ID) http://simple-database-explorer.googlecode.com/files/Main2.jpg Working example: self.model.setData(self.model.index(i, j, QtCore.QModelIndex()), value, role=0) if isNumber(value): ...

PyQt - Function for zooming large Images

Hi, I need a function for zooming very large images (5000 x 7000 pixel) in pyqt. I´ve tried out the functions from gwenview (Image viewer coded in C++ and Qt), but it`s too difficult for me to understand. Thanks! ...

Passing Arguments with Newstyle signals in PyQT

I've been having some trouble with a set of dynamically created buttons in PyQT. I'm using a list to create buttons corresponding to different values. Because each button is different, I need to have them pass an argument to the "Button Clicked" function identifying themselves separately so I can perform different actions with them. He...

swing component in pyqt

Is there a way to run a swing component through a pyqt widget? I'd like to write a small project using pyqt, but there's a java library that draws to a JPanel-inherited panel, and it would be really convenient to be able to embed one into the other. I know I could use jython and qtjambi, but I was curious if there was an alternative su...

What is the grab-command (leftMouseButton) for QGraphicsView.ScrollHandDrag

Hi, you can enable mouse dragging by setting setDragMode(QtGui.QGraphicsView.ScrollHandDrag for QGraphicsView. Then you can drag the QGraphicsScene by holding the leftMouseButton. But I want to drag with the middleMouseButton not leftMouseButton. How can I do that? I tried setCursor(QtCore.Qt.ClosedHandCursor) but it isn't working. Ha...

Cant get a custom ItemDelegate to work

Hello there, first off, im new to python and pyqt so please bear with me. Im using a QTableView with a QSqlTableModel everything works as intended. The last column of the view contains only 0 and 1 as value which i want to display as checkbox and this column should be editable. Ive read that you should subclass QItemDelegate which i d...

Qt4 - Updating the gui from a different thread

In C# you can do the following whenever you need to update the gui from another thread: control.Invoke(delegate() { // Do whatever you want in the gui thread here }); Is there something similar and as simple for Qt4? (PyQt4 specifically) I would rather not get into signals, slots, and use native threads instead of QThreads if po...

How do I subclass QApplication properly?

I am a newbie with PyQt4 (and QT altogether), and am facing a problem, I have subclassed QApplication (to have global data and functions that really are global to the application): class App(QApplication): def __init__(self): QApplication.__init__(self) self.foo = None def bar(self,x): do_something() ...

PyQt4 SIGNAL/SLOT problem when using sub-directories

Thanks in advance for taking the time to read this. Apologies that it is somewhat verbose. But hopefully it fully explains the problem. Stripped code demonstrating the issue is included. I'm having an issue with PyQt4 SIGNAL/SLOTS. While I can make everything work fine if I am writing in a single file, I can't make things work if I some...