pyqt

Using PyQt signals correctly

A while ago I did some work in Qt for C++; now I'm working with PyQt. I have a subclass of QStackedWidget, and inside that a subclass of QWidget. In the QWidget I want to click a button that goes to the next page of the QStackedWidget. My (simplified) approach is as follows: class Stacked(QtGui.QStackedWidget): def __init__(self, p...

Python: OSX Library for fast full screen jpg/png display

Frustrated by lack of a simple ACDSee equivalent for OS X, I'm looking to hack one up for myself. I'm looking for a gui library that accommodates: Full screen image display High quality image fit-to-screen (for display) Low memory usage Fast display Reasonable learning curve (the simpler the better) Looks like there are several choic...

QTreeWidget expand sign

Hi everyone, How to make expandable sign in QTreeWidget always visible even when item doest have any subitems? And how to draw something else instead of default sign? Thanks in advance, Serge ...

QTreeWidget activate item signals

Hi everyone, I need to do some actions when item in QTreeWidget activates, but following code doestn't gives me expected result: class MyWidget(QTreeWidget): def __init__(self, parent=None): super(MyWidget, self).__init__(parent) self.connect(self, SIGNAL("activated(QModelIndex)"), self.editCell) def editCell...

PyQt: How to keep QTreeView nodes correctly expanded after a sort

I'm writing a simple test program using QTreeModel and QTreeView for a more complex project later on. In this simple program, I have data in groups which may be contracted or expanded, as one would expect in a QTreeView. The data may also be sorted by the various data columns (QTreeView.setSortingEnabled is True). Each tree item is a lis...

QTreeWidget set height of each row depending on content

Hi everyone, I want to make editable cells with multi-lines content in QTreeWidget and I use for this purpose QPlainTextEdit as a delegate. I need to set proper size to all rows that switching between editing and displaying went smooth, without any visible changes. rect = textEdit.blockBoundingRect(textEdit.firstVisibleBlock()) wit...

PyQt error: QSqlDatabasePrivate::database: unable to open database

What is the cause of following error: QSqlDatabasePrivate::database: unable to open database: unable to open database file Error opening database? Code is 100% correct, this message appeared when I have reinstalled Windows, Python and PyQt. EDIT: I have "read-only" flag in folder with .db file properties. It stays gray (half-checked) w...

resizing row's height in QTreeWidget/QTreeView

Hi everyone, I have some problems with sizing row's height in QTreeWidget. I use QStyledItemDelegate with QPlainTextEdit. During editing text in QPlainTextEdit i check for changes with a help of: rect = self.blockBoundingRect(self.firstVisibleBlock()) and if text's height changes i resize editor size and need row in QTreeWidget also ...

"IronPython + .NET" vs "Python + PyQt". Which one is better for Windows App development?

Hi, I'm new in using Python. I would like to develop Windows GUI Application using Python. After some research, I found that I have 2 options:- IronPython + .NET Framework Python + PyQt May I know which one is better for Windows Application development? Which option has more features (e.g. database support, etc)? Other than the .NE...

Qt: How to autoexpand parents of a new QTreeView item when using a QSortFilterProxyModel

I'm making an app wherein the user can add new data to a QTreeModel at any time. The parent under which it gets placed is automatically expanded to show the new item: self.tree = DiceModel(headers) self.treeView.setModel(self.tree) expand_node = self.tree.addRoll() #addRoll makes a node, adds it, and returns the (parent) note to be expa...

My QFileSystemModel doesn't work as expected in PyQt

EDIT2: model.hasChildren(parentIndex) returns True, but model.rowCount(parentIndex) returns 0. Is QFileSystemModel just fubar in PyQt? EDIT: With a bit of adaptation this all works exactly as it should if I use QDirModel. This is deprecated, but maybe QFileSystemModel hasn't been fully implemented in PyQt? I'm learning the Qt Model/V...

Editable QTreeView with expandable cells

Hi everyone, I tried to write an editable table based on QTreeView with wordwraped content in cells which in turn should expand in height (that whole text was visible) like usual cells in tables like in MSWord, but have met insuperable obstacles: first - i can't set fixed cell size. second - i can't make text display in cells wordwra...

How can I view and print PDFs in Python?

Is there a GPL or less restrictive (preferred LGPL) library to view & print PDFs? I'm using PyQt, maybe there's a possibility to render PDFs using it? ...

Right clicking on QHeaderView inside of QTreeView

I've written a descendant of QTreeView with multiple columns. I want to create a popup menu that appears whe nthe user right-clicks over the column headers. I have tried catching signals from QTreeView for this, but QTreeView doesn't seem to emit signals on the headers. QTreeView.header() does. I therefore believe I must either: 1: conne...

How to make tree structured text editor in Qt/Pyqt?

Hi everyone, can you advice what to use for making tree structured text editor? I used QTreeView for this (asked few questions to solve my problems), but it seams it's not suitable for this purpose. Thanks in advance, Serge ...

Key/Value pyqt QComboBox

I want to use a QComboBox with the "keys" and "values" from a tuple similar to the ones used in a django models. For example I have the following structure for a person's sex. SEX_CHOICES = (('M', 'Male'), ('F', 'Female')) The first item of the tuple contains the code of the sex that is stored in the database, and the second one the t...

Need some help with PyQt and QGridLayout

I'm having an annoyingly stubborn problem here, and I would appreciate it if anyone could give me some insight into what I'm doing wrong. I have a PyQt app that is supposed to display a table of numbers. So, naturally, I am using QTableWidget. Right now, it's extremely simple: all I do is create a window with a Table Widget and a button...

Tying PyQt4 QAction triggered() to local class callable doesn't seem to work. How to debug this?

I create this object when I want to create a QAction. I then add this QAction to a menu: class ActionObject(object): def __init__(self, owner, command): action = QtGui.QAction(command.name, owner) self.action = action self.command = command action.setShortcut(command.shortcut) action.setStatusTip(command.name) ...

Problem with set[Left|Right|Top|Bottom]Margin for QTextBlock in QTextEdit/QPlainTextEdit

Hi everybody, how can i set different margins for each QTextBlock in QTextEdit/QPlainTextEdit? i tried to set it with following code: class MyWidget(QPlainTextEdit): def func(self): block = self.firstVisibleBlock() while block.isValid(): block = block.next() block.blockFormat().setLeftMarg...

QPluginLoader with PyQt modules as plugins: possible?

Hi! I have a C++ application that loads externals plugins thanks to QPluginloader. QPluginLoader provides access to a Qt plugin. A Qt plugin is stored in a shared library (a DLL). The plugins have to inherit from a pure virtual class ( and Q_DECLARE_INTERFACE ) and QObject. I would like to create plugins by using python and PyQt. Is t...