[PyQt] kde4: where is pykdedocs?
Hi, on kubuntu 8.10, the file /usr/share/doc/python-kde4-doc/html/pykdedocs.html says there is a script installdocs.py for installing kykdedocs. Where can I find this script? Not on my computer, and I think I installed all relevant packages. specifically, I am trying to do something like self.actionNewHand = KAction(i18n("&New hand"), "newhand", kdecore.KStdAccel.key(kdecore.KStdAccel.New), self, self.newHand, self.actionCollection()); but I dont know how to make use of KStdAccel: kdecore.KStdAccel.key( AttributeError: 'module' object has no attribute 'KStdAccel' -- Wolfgang ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] QSqlDatabase: available drivers: QSQLITE
On Donnerstag, 18. Dezember 2008, lucabe...@libero.it wrote: > I need to connect to mysql db but when i try i see that i have only availabe > the driver for sqlite, how can i add the mysql driver? maybe you need to install the package libqt4-sql-mysql (I am running ubuntu) -- Wolfgang ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Re: Is it possible to subclass QSqlDatabase?
On Freitag, 6. Februar 2009, Mattia Borsalino wrote: > class MyDatabase(QSqlDatabase): > """ > subclasses QSqlDatabase > """ > def __init__(self, parent=None): > super(MyDatabase, self).__init__(parent) according to the docu, parent should either not be passed or it should be another QSqlDatabase. this works: def __init__(self, parent=None): super(MyDatabase, self).__init__() -- Wolfgang ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Re: LGPL license.
On Dienstag, 10. Februar 2009, Knapp wrote: > Why do we live? not for searching the pyqt archives :-) -- Wolfgang ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] QString mutable, unicode string immutable
Hi, I just found out the hard way what the subject says Now I am curious: The PyQt roadmap says that non-pythonic classes like QString will be removed. So the result of some Qt/KDE methods will no longer return a mutable result but an immutable result. Could this not break code that relies on the result being mutable? This is the concrete case I had: In a class derived from kdeui.KConfigSkeleton: (this code is edited to a minimum, might not run) self._value = QString() self.configValue = self.addItemString('value',self._value,QString('default')) after the config dialog I save the new value elsewhere: saveValue = config.configValue.value() now saveValue is a QString after next config dialog I check if the value changed: if saveValue != config.configValue.value(): self.applyChanges() but since theye are QStrings, they are always identical - the config dialog also changes my saveValue. of course the solution is simple: saveValue = str(config.configValue.value()) -- Wolfgang ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Re: PyQT lost reference (was: Re: PyKDE: KConfigSkeleton not writing configuration)
On Freitag, 13. März 2009, Till Gerken wrote: > The QString() that I am passing as reference to the C++ class > KCoreConfigSkeleton exists as local variable in my Python class > derived from KCoreConfigSkeleton. Now any code that interacts with > KCoreConfigSkeleton (C++ or Python) may change this QString instance. this is because QString() is mutable while python strings are immutable. When dealing with KCoreConfig, do not use QString as local variables, always convert explicitly from/to python strings. I wonder what happens with this when the QString will be eliminated in PyQt4 as announced. That might break code which relies on QString being mutable. See my message http://www.mail-archive.com:80/pyqt@riverbankcomputing.com/msg16594.html -- Wolfgang ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Re: PyQT lost reference (was: Re: PyKDE: KConfigSkeleton not writing configuration)
On Freitag, 13. März 2009, Phil Thompson wrote: > Which is why eliminating QStrings is an incompatible change and will > require changes to your code. Sorry, it seems I misread your roadmap - I thought this would be a compatible change. -- Wolfgang ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] dragging a QGraphicsSvgItem
While dragging it, I want to see the whole image of the item move. What works is something like this: (code goes into class Tile(QGraphicsSvgItem), def mousePressEvent) ... pmapSize = self.tileset.tileSize.toSize() if self.pixmap is None or self.pixmap.size() != pmapSize: self.pixmap = QPixmap(pmapSize) self.pixmap.fill(Qt.transparent) painter = QPainter(self.pixmap) QGraphicsSvgItem.paint(self, painter, QStyleOptionGraphicsItem()) for item in self.childItems(): QGraphicsSvgItem.paint(item, painter, QStyleOptionGraphicsItem()) drag.setPixmap(self.pixmap) drag.setHotSpot(event.pos().toPoint()) but I do not want to render a SVG that is already rendered Is there any way I can avoid rendering this item twice? Did I overlook a QGraphicsSvgItem method that would return its rendered pixmap? -- Wolfgang ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Re: dragging a QGraphicsSvgItem
On Mittwoch, 18. März 2009, Matt Smith wrote: > I use a graphics scene and I never have to explicitly paint anything. > It seems like you could create a pixmap item when you load the svg then > you wouldn't have to render it again later. My view scales the svg images matching to the available space, so when I change the view size I would have to scale the pixmap too or regenerate it. For the same reason I was wrong to use qgraphicsitem events - I have to do it all on the view. Otherwise I could not scale the drag pixmap to the item size in the view. -- Wolfgang ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] caching qgraphicssvgitem is buggy
I am using qt4.5 with python-qt4.4.4 (ubuntu jaunty) In my application I have a qgraphicssvgitem. When I change the element to be rendered with setElementId(), this change does not do anything. I still see the old element displayed. Only after I invalidate the cache or resize the view (which also resizes the graphicssvgitem) the correct new element is shown. If I disable caching, I have no problems either. the two elements have the same size and the names TILE_1 and TILE_2 Could this be a problem with pyqt, or rather with qt4.5? The list of bugs to be fixed with 4.5.1 does not mention this. I checked the qt4.5 code: void QGraphicsSvgItem::setElementId(const QString &id) { Q_D(QGraphicsSvgItem); d->elemId = id; d->updateDefaultSize(); update(); } -- Wolfgang ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] segfault with KXmlGuiWindow
This is a problem since I started using pykde, it persists after updating from kubuntu intrepid to jaunty. See the example below. At program exit, I have a segfault. If I remove "def main" and execute its content directly, I have no segfault. But this is no real solution for me because in my full program the segfault happens in both cases. Is there something wrong in my python code? import sys from PyKDE4 import kdecore, kdeui class MainWnd(kdeui.KXmlGuiWindow): def __init__(self): super(MainWnd, self).__init__() kdeui.KStandardAction.quit(kdeui.KApplication.kApplication().quit, self.actionCollection()) self.setupGUI() def main(): about = kdecore.KAboutData ("bug", "", kdecore.ki18n("bug"), "0.1") kdecore.KCmdLineArgs.init (sys.argv, about) app = kdeui.KApplication() mainWindow = MainWnd() mainWindow.show() app.exec_() if __name__ == "__main__": main() I have python-qt4 4.2.2 python-kde4 4.2.2 libqt4.5.0 python 2.6.1 this is what valgrind tells me: ==12561== Invalid read of size 4 ==12561==at 0x5D659B5: QWidget::~QWidget() (qwidget.cpp:1357) ==12561==by 0x6161920: QMainWindow::~QMainWindow() (qmainwindow.cpp:328) ==12561==by 0x716E13A: KMainWindow::~KMainWindow() (kmainwindow.cpp:467) ==12561==by 0x71B1266: KXmlGuiWindow::~KXmlGuiWindow() (kxmlguiwindow.cpp:127) ==12561==by 0x6B0D377: sipKXmlGuiWindow::~sipKXmlGuiWindow() (sipkdeuipart0.cpp:8222) ==12561==by 0x6AD327F: release_KXmlGuiWindow (sipkdeuipart0.cpp:12403) ==12561==by 0x6AD32D6: dealloc_KXmlGuiWindow (sipkdeuipart0.cpp:12417) ==12561==by 0x47D45A2: sipWrapper_dealloc (siplib.c:7543) ==12561==by 0x80A9104: subtype_dealloc (typeobject.c:1018) ==12561==by 0x816719E: frame_dealloc (frameobject.c:417) ==12561==by 0x80DF5B4: PyEval_EvalFrameEx (ceval.c:3794) ==12561==by 0x80E00C7: PyEval_EvalCodeEx (ceval.c:2968) ==12561==by 0x80E0226: PyEval_EvalCode (ceval.c:522) ==12561==by 0x80FE2E0: PyRun_FileExFlags (pythonrun.c:1334) ==12561==by 0x80FE631: PyRun_SimpleFileExFlags (pythonrun.c:930) ==12561==by 0x805C8B1: Py_Main (main.c:599) ==12561==by 0x805B9A1: main (python.c:23) ==12561== Address 0x4 is not stack'd, malloc'd or (recently) free'd ==12561== ==12561== Process terminating with default action of signal 11 (SIGSEGV) ==12561== Access not within mapped region at address 0x4 ==12561==at 0x5D659B5: QWidget::~QWidget() (qwidget.cpp:1357) ==12561==by 0x6161920: QMainWindow::~QMainWindow() (qmainwindow.cpp:328) ==12561==by 0x716E13A: KMainWindow::~KMainWindow() (kmainwindow.cpp:467) ==12561==by 0x71B1266: KXmlGuiWindow::~KXmlGuiWindow() (kxmlguiwindow.cpp:127) ==12561==by 0x6B0D377: sipKXmlGuiWindow::~sipKXmlGuiWindow() (sipkdeuipart0.cpp:8222) ==12561==by 0x6AD327F: release_KXmlGuiWindow (sipkdeuipart0.cpp:12403) ==12561==by 0x6AD32D6: dealloc_KXmlGuiWindow (sipkdeuipart0.cpp:12417) ==12561==by 0x47D45A2: sipWrapper_dealloc (siplib.c:7543) ==12561==by 0x80A9104: subtype_dealloc (typeobject.c:1018) ==12561==by 0x816719E: frame_dealloc (frameobject.c:417)
[PyQt] Re: Connecting two QGraphicsItems
On Montag, 6. April 2009, Marcell Mars wrote: > On Mon, Apr 6, 2009 at 4:13 PM, Mads wrote: > > each item needs to have separate functionality, so you should be able to > > set different > > attributes on each item. Is the createItemGroup, still the best way forward? > > to be more sure i would need more info about your app but as i saw i > would definitively try createItemGroup and QGraphicsView.. i love > QGraphicsView why not simply make the 3 circles children of the rectangle with circle.setParentItem(rectangle)? The drawing seems to say that the line of the rectangle should not be visible below the circles. -- Wolfgang ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Re: QWebView in QGraphicsScene - drag and drop issue
On Montag, 6. April 2009, Tom Batkiewicz wrote: > I get a hard crash with the following code if you drag/drop inside a > QWebView that is being rendered inside of a QGraphicsScene. > The trick is that it functions properly if you use addWidget() to > directly put the widget into the scene, but if you create the proxy > yourself and call setWidget() before adding the proxy to the scene you > get the crash. your code works here. Pyqt 4.4.4, Qt 4.5. At least I have no crash, otherwise when I resize the window only parts of it are redrawn correctly. is the OpenGl dependency needed to make it crash? -- Wolfgang ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Re: Connecting two QGraphicsItems
On Thursday, 9. April 2009, Mads wrote: > is it possible to control the position of the item? just use item.setPos() - this uses a coordinate system relative to the parent item. -- Wolfgang ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Re: tooltips in menu: how?
On Saturday, 18. April 2009, projetmbc wrote: > V. Armando Solé is right. With this solution the tooltips come quickly > in my computer. The corresponding PyQt code is : this code works here too - but not always. First place the mouse over the menu and wait until the tooltip "Click here..." appears now click on it and move the mouse to the menu entries. No tooltips. They only appear if the "click here..." was not visible when opening the menu. I have libqt4.5 and pyqt4.4 Maybe somebody (not me) should try this in C++ -- Wolfgang ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Re: tooltips in menu: how?
On Sonntag, 19. April 2009, projetmbc wrote: > This is normal. When the menu is activated ther is no reason to give a > tooltip about it because we know wath is in. let me restate what I observed: if the tip click here... appears, the tips "tooltip 0" etc will never appear unless the program is restarted if the tip click here... does not appear, the tips "tooltip 0" etc will appear this is inconsistent behaviour. Even worse: 1. wait for the tooltip "click here" to appear 2. open the menu and click on any menu entry. 3. the tool tip "click here" will never appear again don't you observe this behaviour? What versions are you using? -- Wolfgang ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Qt.WindowCloseButtonHint undefined
Hello, flags = self.windowFlags() newflags = flags | Qt.WindowStaysOnTopHint newflags = flags & ~ Qt.WindowCloseButtonHint self.setWindowFlags(newflags) self.show() AttributeError: WindowCloseButtonHint WindowStaysOnTopHint is defined, but not WindowCloseButtonHint. looking at http://doc.trolltech.com/4.5/qt.html#WindowType-enum I cannot see why. Could the QT documentation be wrong by not stating that WindowCloseButtonHint is new with libqt4.5, or is the pyqt interface incomplete? I have libqt 4.5.0, pyqt 4.4.4, python-sip4 4.7.9 on kubuntu 9.04 -- Wolfgang ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Qt.WindowCloseButtonHint undefined
On Sonntag, 7. Juni 2009, Phil Thompson wrote: > It was added in Qt v4.5. thank you. -- Wolfgang ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] determining pyqt version
I am doing that with: import PyQt4.pyqtconfig PYQTVERSION = PyQt4.pyqtconfig.Configuration().pyqt_version_str but now that I tried to deploy it I see that this imports sipconfig which is part of the ubuntu package python-sip4-dev I do not want to depend on -dev packages on target machines, is there any other way to find out the current version? -- Wolfgang ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] determining pyqt version
On Saturday 18 July 2009, Phil Thompson wrote: > On Sat, 18 Jul 2009 11:59:23 +0200, Wolfgang Rohdewald > wrote: > > is there any other way to find out the current version? > > PyQt4.QtCore.PYQT_VERSION_STR > PyQt4.QtCore.PYQT_VERSION thank you! -- Wolfgang ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Re: Those bl**dy signals again
On Saturday 03 October 2009, Thomas Olsen wrote: > def amount_editing_finished() that should return a syntax error, missing ":" should that not be def amount_editing_finished(self): -- Wolfgang ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Re: Global Shorcuts
On Wednesday 04 November 2009, Manuel Enrique wrote: > How can I set a global shorcut for my app? look up setShortcutContext in the docu: res = KAction(self) # should also work with QAction, I suppose res.setShortcut( Qt.CTRL + shortcut) res.setShortcutContext(Qt.ApplicationShortcut) -- Wolfgang ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Kajongg - a new game base on PyQt and twisted
I would like to announce Kajongg - it is a Mah Jongg game (not yet another solitaire but the real game for four players). It is written 100% in python and regular expressions. The GUI is done with PyQt4, and the network part is written using twisted. Dear twisted people - you have a list of projects using twisted - if you want to add Kajongg, please go ahead! http://www.kde-apps.org/content/show.php/kajongg?content=103206 source code: svn co svn://anonsvn.kde.org/home/kde/trunk/playground/games/kajongg -- Wolfgang ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Sudoku Grid - Recommended Approaches
On Thursday 04 February 2010, Kareem Yusuf wrote: > I'm looking for some advice on the best way to implement a sudoku > grid using PyQt. I am new to PyQt and Python so my following > thoughts are shaped by other language experiences (c# and Java). did you consider a QGraphicsScene and QGraphicsRectItem for the squares? The more eye candy you want the more this probably makes sense. And you never have to worry about scaling issues. I implemented a class for such a grid that way for Kajongg where the grid holds Mah Jongg tiles. Your grid should be easier since you have no shadows, no partial offsets and no rotated items to consider. -- Wolfgang ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Problem with KDialogButtonBox.addButton
Hi, how can I pass my own python slot to addButton? def slotInsert(self): pass newItem = KGuiItem(QString("&New"), KIcon("document-new")) self.newButton = self.buttonBox.addButton(newItem, KDialogButtonBox.ActionRole, self, self.slotInsert) TypeError: KDialogButtonBox.addButton(): arguments did not match any overloaded call: overload 1: argument 1 has unexpected type 'KGuiItem' overload 2: argument 1 has unexpected type 'KGuiItem' overload 3: argument 4 has unexpected type 'instancemethod' overload 4: argument 3 has unexpected type 'PlayerList' This is KDE 4.4 with pyqt4 4.7.0 -- Wolfgang ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] How to retrieve number of fields of a query from QSqlQuery object
On Mittwoch 24 März 2010, bar tomas wrote: > Hi, > QSqlQuery's size method gives the number of rows retrieved > with a query. But is there some way to get the number of > fields (columns) of that query? > Many thanks. if self.query.isSelect(): record = self.query.record() qFields = [record.field(x) for x in range(record.count())] -- Wolfgang ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] QMessagebox.exec_() documentation
the doc at http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qmessagebox.html#exec says that the exec_() slot returns the StandardButtons value of the button that was clicked. The C++ doc says if user defined buttons are used, an opaque value is returned. This is not mentioned in the PyQt4 doc. exec_() is only used in examples but not explicitly defined so I would expect it to behave like the inherited QDialog.exec_() In the class below, QMessageBox.exec_() returns 0 for for the button with the YesRole and 1 for the button with the NoRole. Why is that so? Could this be an index into the button list? It certainly is not a QMessageBox.ButtonRole value. Using pyqt 4.7.2 on kubuntu 10.04 class SwapDialog(QMessageBox): def __init__(self, swappers): QMessageBox.__init__(self) self.setWindowTitle(m18n("Swap Seats") + ' - Kajongg') self.setText("By the rules, %s and %s should now exchange their seats. " % \ (swappers[0].name, swappers[1].name)) self.yesAnswer = QPushButton("&Exchange") self.addButton(self.yesAnswer, QMessageBox.YesRole) self.noAnswer = QPushButton("&Keep seat") self.addButton(self.noAnswer, QMessageBox.NoRole) def exec_(self): QMessageBox.exec_(self) # ignore strange exec_ return value return self.clickedButton() == self.yesAnswer -- Wolfgang ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] vertical alignment of richtext in a table view
Hi, in Mark Summerfields book "Rapid GUI programming with Python and QT", there is an example on page 485 with a table column having a delegate that displays richtext. In the book, the text in this column has a vertical alignment in the middle of the cells, just like the other columns. but if I execute that example (from the downloadable source: chap16/carhirelog.pyw), the rich text is vertically not in the middle but above. How can I make it align vertically just like a normal column? His book has another such table chap14, page 436 / ships_delegate.pyw. Here, both the image in the book and the executable show the same wrong vertical alignment. BTW interesting things happen if the column with richtext is resized to a minimum: the delegate draws outside of its available horizontal space, showing text to the right of the rightmost column. (using pyqt 4.7.3 with qt4-4.7.0-rc1) this is the paint of the delegate: def paint(self, painter, option, index): text = index.model().data(index, Qt.DisplayRole).toString() palette = QApplication.palette() document = QTextDocument() document.setDefaultFont(option.font) if option.state & QStyle.State_Selected: document.setHtml(QString("%2") \ .arg(palette.highlightedText().color().name()) \ .arg(text)) else: document.setHtml(text) painter.save() color = palette.highlight().color() \ if option.state & QStyle.State_Selected \ else QColor(index.model().data(index, Qt.BackgroundColorRole)) painter.fillRect(option.rect, color) painter.translate(option.rect.x(), option.rect.y()) document.drawContents(painter) painter.restore() -- Wolfgang ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] vertical alignment of richtext in a table view
On Montag 06 September 2010, Mark Summerfield wrote: > I'm tending to use a differnt approach for rich text delegates > nowadays. Instead of using a QTextDocument, I store a > class-level QLabel, something like this: your solution certainly looks cleaner than my temporary fix (document.setDocumentMargin(7.0)), and it solves the problem of painting outside of the field. but it does not quite work for me. Your untested example leaves the fields blank, it seems I have to give the renderer a position. Using view.pos() + option.rect.topLeft(), labels are still too far up and left. The magical offset (3,25) puts them all in the right place. How can I compute the correct place instead? class RichTextColumnDelegate(QtGui.QItemDelegate): label = QtGui.QLabel() def __init__(self, parent=None): super(RichTextColumnDelegate, self).__init__(parent) def paint(self, painter, option, index): text = index.model().data(index, QtCore.Qt.DisplayRole).toString() self.label.setText(text) self.label.setFixedSize(option.rect.size()) view = self.parent().parent().view topLeft = view.pos() + option.rect.topLeft() + QtCore.QPoint(3, 25) self.label.render(painter, topLeft) def sizeHint(self,option,index): # still uses QTextDocument as in your book -- Wolfgang ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] vertical alignment of richtext in a table view
On Dienstag 07 September 2010, Mark Summerfield wrote: > I should have mentioned before that it is better to inherit > from QStyledItemDelegate rather than QItemDelegate. I'd try > that first & see if that improves things at all. makes no difference. > The offset you need might be made up of the > option.decorationSize's width; not sure about the height > offset. decorationSize is (16,16) - that does not explain it. > Using QTextDocument is fine for computing the size hint, > although for efficiency you might create a class-level > QTextDocument and reuse it. done. > (There are other possibilities > too, that I cover in Advanced Qt Programming, but can't > recall off hand.) just ordered. I hope it is as excellent as your book about rapid GUI programming with Python and Qt. my latest version of this delegate is here: http://websvn.kde.org/trunk/KDE/kdegames/kajongg/src/genericdelegates.py?view=markup -- Wolfgang ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] KConfigSkeleton and pyqt4 API version 2
Hi, this code prints random output. How should I fix this? import sip sip.setapi('QString', 2) from PyKDE4.kdeui import KConfigSkeleton a = KConfigSkeleton() name = 'tilesetName' value = 'I am a value' s = a.addItemString(name, value) print s.value() == output: == value is: 䱀Ɨ!䱠Ɨ彐Ɨ美繈 *** glibc detected *** python: corrupted double-linked list: 0x01975f50 *** ii python-qt4 4.7.3-1ubuntu2~lucid1~ppa3 Python bindings for Qt4 ii python-kde4 4:4.5.1-0ubuntu1~lucid1~ppa1Python bindings for the KDE 4 libraries -- Wolfgang ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] KConfigSkeleton and pyqt4 API version 2
On Freitag 17 September 2010, Hans-Peter Jansen wrote: > first of all, this is the wrong list for PyKDE issues. Try to > resend this to the kde-bindings ML: will do, thank you for pointing me there. > You're missing to create a {Q,K}Application instance here. not needed for this minimal example, I would have thought. It certainly shows the same problem as the full application. But I should have tried with gdb - my code actually gives a nice backtrace at exit time Program received signal SIGSEGV, Segmentation fault. ~QString (node=0xcf6cff) at /usr/include/qt4/QtCore/qstring.h:882 882 inline QString::~QString() { if (!d->ref.deref()) free(d); } (gdb) bt #0 ~QString (node=0xcf6cff) at /usr/include/qt4/QtCore/qstring.h:882 #1 ~QHashNode (node=0xcf6cff) at /usr/include/qt4/QtCore/qhash.h:217 #2 QHash::deleteNode2 (node=0xcf6cff) at /usr/include/qt4/QtCore/qhash.h:519 #3 0x7428cc6d in QHashData::free_helper (this=0xcf5160, node_delete= 0x747520d0 ::deleteNode2(QHashData::Node*)>) at tools/qhash.cpp:271 #4 0x7474ee70 in QHash::freeData (this=0xcad330, __in_chrg=) at /usr/include/qt4/QtCore/qhash.h:568 #5 ~QHash (this=0xcad330, __in_chrg=) at /usr/include/qt4/QtCore/qhash.h:284 #6 ~Private (this=0xcad330, __in_chrg=) at ../../kdecore/config/kcoreconfigskeleton_p.h:40 #7 ~KCoreConfigSkeleton (this=0xcad330, __in_chrg=) at ../../kdecore/config/kcoreconfigskeleton.cpp:1005 #8 0x75e6fecc in sipKConfigSkeleton::~sipKConfigSkeleton() () from /usr/lib/pymodules/python2.6/PyKDE4/kdeui.so #9 0x75e02cbc in ?? () from /usr/lib/pymodules/python2.6/PyKDE4/kdeui.so #10 0x767a77f9 in ?? () from /usr/lib/pymodules/python2.6/sip.so #11 0x0046d2d8 in subtype_dealloc (self=) at ../Objects/typeobject.c:1019 #12 0x0044e577 in insertdict (mp=0x8c8270, key='a', hash=12416037344, value=None) at ../Objects/dictobject.c:459 #13 0x00450a77 in PyDict_SetItem (op= {'a': None, 'sip': , 'name': 'tilesetName', '__builtins__': , 'KConfigSkeleton': , 'value': 'I am a value', '__package__': None, 's': , '__name__': '__main__', '__doc__': None}, key='a', value=None) at ../Objects/dictobject.c:701 #14 0x0045297e in _PyModule_Clear (m=) at ../Objects/moduleobject.c:138 #15 0x004bb5fa in PyImport_Cleanup () at ../Python/import.c:441 #16 0x004c922f in Py_Finalize () at ../Python/pythonrun.c:438 #17 0x0041a296 in Py_Main (argc=-135380864, argv=) at ../Modules/main.c:596 #18 0x769d9c4d in __libc_start_main (main=, argc=, ubp_av=, init=, fini=, rtld_fini=, stack_end=0x7fffddc8) at libc-start.c:226 #19 0x004199f9 in _start () -- Wolfgang ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] pyuic4 vs uic.loadUI
On Dienstag 28 September 2010, Sebastian Wiesner wrote: > So basically it "just works", whereas pyuic4 means additional > work. UI compilers are fine for C++, where you have to > compile anyway, but in Python things are easier. Just my > opinion ... +1 however I never tested how much time either variant takes for the application to start. In my case, kajongg, there are only 2 small .ui so time does not matter -- Wolfgang ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] dead link at riverbankcomputing.co.uk
this page http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/pyqt4ref.html#downloading- sip has a dead link to the SIP documentation -- Wolfgang ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] unicode and pyqt4
On Mittwoch 24 November 2010, Janwillem van Dijk wrote: > When I run the script from > Eric4 or directly from a terminal with "python scriptname.py" > all is OK. However I want to run it as a subprocess and than > the special chars generate errors: if stdout is pipelined, python tries to encode its output to ascii. The following is my solution for python2.6: from locale import getpreferredencoding from sys import stdout try: STDOUTENCODING = stdout.encoding except AttributeError: STDOUTENCODING = None if not STDOUTENCODING: STDOUTENCODING = getpreferredencoding() def kprint(*args, **kwargs): """a wrapper around print, always encoding unicode to something sensible""" newArgs = [unicode(x).encode(STDOUTENCODING) for x in args] # we need * magic: pylint: disable=W0142 print(*newArgs, sep=kwargs.get('sep', ' '), end=kwargs.get('end', '\n'), file=kwargs.get('file')) -- Wolfgang ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] QStandardItemEditorCreator missing
On Donnerstag 25 November 2010, Hans-Peter Jansen wrote: > If you run the scripts, and press "Arrow left", "blank", > "Arrow down", "Return", "Return", something similar the > following is printed: you probably mean "Arrow right", "blank", "Arrow down", "Return", "Return" I attached the interesting parts of valgrind output. -- Wolfgang valgrind --trace-children=yes ./coloreditorfactory-qvariant.py ==14984== Invalid read of size 4 ==14984==at 0x935C6B9: void v_construct(QVariant::Private*, void const*, QColor*) (qcolor.h:292) ==14984==by 0x935B246: construct(QVariant::Private*, void const*) (qguivariant.cpp:105) ==14984==by 0x78784BE: QVariant::QVariant(int, void const*) (qvariant.cpp:1670) ==14984==by 0x7862A97: QMetaProperty::read(QObject const*) const (qmetaobject.cpp:) ==14984==by 0x786B946: QObject::property(char const*) const (qobject.cpp:3469) ==14984==by 0x991B52E: QStyledItemDelegate::setModelData(QWidget*, QAbstractItemModel*, QModelIndex const&) const (qstyleditemdelegate.cpp:538) ==14984==by 0x9872125: QAbstractItemView::commitData(QWidget*) (qabstractitemview.cpp:2759) ==14984==by 0x8B2169A: sipQTableWidget::commitData(QWidget*) (sipQtGuipart2.cpp:29575) ==14984==by 0x986C377: QAbstractItemView::qt_metacall(QMetaObject::Call, int, void**) (moc_qabstractitemview.cpp:247) ==14984==by 0x98A1B34: QTableView::qt_metacall(QMetaObject::Call, int, void**) (moc_qtableview.cpp:118) ==14984==by 0x98DE675: QTableWidget::qt_metacall(QMetaObject::Call, int, void**) (moc_qtablewidget.cpp:135) ==14984==by 0x8B220EB: sipQTableWidget::qt_metacall(QMetaObject::Call, int, void**) (sipQtGuipart2.cpp:28863) ==14984== Address 0x117aa88c is 12 bytes inside a block of size 32 free'd ==14984==at 0x4C27A83: operator delete(void*) (vg_replace_malloc.c:387) ==14984==by 0x9358B9F: clear(QVariant::Private*) (qvariant_p.h:142) ==14984==by 0x7878B8E: QVariant::clear() (qvariant.cpp:1862) ==14984==by 0x787A9C2: QVariant::operator=(QVariant const&) (qvariant.cpp:1803) ==14984==by 0x7447F7E: Chimera::fromPyObject(_object*, QVariant*, bool) const (in /usr/lib/pyshared/python2.6/PyQt4/QtCore.so) ==14984==by 0x7441F97: qt_metacall_worker(_sipSimpleWrapper*, _typeobject*, _sipTypeDef*, QMetaObject::Call, int, void**) (in /usr/lib/pyshared/python2.6/PyQt4/QtCore.so) ==14984==by 0x7442141: qpycore_qobject_qt_metacall(_sipSimpleWrapper*, _sipTypeDef*, QMetaObject::Call, int, void**) (in /usr/lib/pyshared/python2.6/PyQt4/QtCore.so) ==14984==by 0x7862A6A: QMetaProperty::read(QObject const*) const (qmetaobject.cpp:2216) ==14984==by 0x786B946: QObject::property(char const*) const (qobject.cpp:3469) ==14984==by 0x991B52E: QStyledItemDelegate::setModelData(QWidget*, QAbstractItemModel*, QModelIndex const&) const (qstyleditemdelegate.cpp:538) ==14984==by 0x9872125: QAbstractItemView::commitData(QWidget*) (qabstractitemview.cpp:2759) ==14984==by 0x8B2169A: sipQTableWidget::commitData(QWidget*) (sipQtGuipart2.cpp:29575) ==14984== ==14984== Invalid read of size 8 ==14984==at 0x935C6C0: void v_construct(QVariant::Private*, void const*, QColor*) (qcolor.h:293) ==14984==by 0x935B246: construct(QVariant::Private*, void const*) (qguivariant.cpp:105) ==14984==by 0x78784BE: QVariant::QVariant(int, void const*) (qvariant.cpp:1670) ==14984==by 0x7862A97: QMetaProperty::read(QObject const*) const (qmetaobject.cpp:) ==14984==by 0x786B946: QObject::property(char const*) const (qobject.cpp:3469) ==14984==by 0x991B52E: QStyledItemDelegate::setModelData(QWidget*, QAbstractItemModel*, QModelIndex const&) const (qstyleditemdelegate.cpp:538) ==14984==by 0x9872125: QAbstractItemView::commitData(QWidget*) (qabstractitemview.cpp:2759) ==14984==by 0x8B2169A: sipQTableWidget::commitData(QWidget*) (sipQtGuipart2.cpp:29575) ==14984==by 0x986C377: QAbstractItemView::qt_metacall(QMetaObject::Call, int, void**) (moc_qabstractitemview.cpp:247) ==14984==by 0x98A1B34: QTableView::qt_metacall(QMetaObject::Call, int, void**) (moc_qtableview.cpp:118) ==14984==by 0x98DE675: QTableWidget::qt_metacall(QMetaObject::Call, int, void**) (moc_qtablewidget.cpp:135) ==14984==by 0x8B220EB: sipQTableWidget::qt_metacall(QMetaObject::Call, int, void**) (sipQtGuipart2.cpp:28863) ==14984== Address 0x117aa890 is 16 bytes inside a block of size 32 free'd ==14984==at 0x4C27A83: operator delete(void*) (vg_replace_malloc.c:387) ==14984==by 0x9358B9F: clear(QVariant::Private*) (qvariant_p.h:142) ==14984==by 0x7878B8E: QVariant::clear() (qvariant.cpp:1862) ==14984==by 0x787A9C2: QVariant::operator=(QVariant const&) (qvariant.cpp:1803) ==14984==by 0x7447F7E: Chimera::fromPyObject(_object*, QVariant*, bool) const (in /usr/lib/pyshared/python2.6/PyQt4/QtCore.so) ==14984==by 0x7441F97: qt_metacall_worker(_sipSimpleWrapper*, _typeobject*, _sipTypeDef*, QMetaObject::Call, int, void*
Re: [PyQt] Bugs galore in QAbstractTableModel???
On Samstag 27 November 2010, Ian wrote: > So here are the model and view: you could try to add checks to your methods like in data(): if index.isValid(): if role == Qt.DisplayRole: data() will also be called with role == Qt.CheckStateRole in which case your code returns True or in headerData: if role == Qt.DisplayRole and orientation == Qt.Horizontal: return ...whatever... else: return QVariant() -- Wolfgang ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Bugs galore in QAbstractTableModel???
On Sonntag 28 November 2010, Steve Borho wrote: > I found an updated version of the file here: > > http://bazaar.launchpad.net/~bzr/ubuntu/maverick/qbzr/bzr-ppa/ > annotate/head:/lib/tests/modeltest.py this still needs more updates. Mostly for editable models. Like -c = insert.pop() +c = self.insert.pop() or -assert(c['last'] == self.model.data(model.index(start-1, 0, c['parent']))) +assert(c['last'] == self.model.data(self.model.index(start-1, 0, c['parent']))) also, the alignment test around line 289 seem to be too strict. Qt.alignLeft|Qt.alignTop does actually align at top (try with a row containing a check box), so why should it be invalid? I am working on making my models bug free by using modeltest (although they do work fine as they are) - when done I will publish my new modeltest.py -- Wolfgang ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Bugs galore in QAbstractTableModel???
On Sonntag 28 November 2010, Steve Borho wrote: > Indeed, I found these when I started using the file, and > checked in a fixed version here: > > http://bitbucket.org/tortoisehg/thg/src/tip/tortoisehg/hgqt/mo > deltest.py here are some more bug fixes for editable models. The patch is against your file. I changed the alignment checks to match http://qt.gitorious.org/qt/qt/blobs/4.7/tests/auto/modeltest/modeltest.cpp -- Wolfgang --- modeltest0.py 2010-11-29 11:29:19.247958003 +0100 +++ modeltest.py 2010-11-29 11:01:20.997958008 +0100 @@ -262,10 +262,7 @@ variant = self.model.data(self.model.index(0,0,QtCore.QModelIndex()), QtCore.Qt.TextAlignmentRole) if variant.isValid(): alignment = variant.toInt()[0] -assert( alignment == QtCore.Qt.AlignLeft or -alignment == QtCore.Qt.AlignRight or -alignment == QtCore.Qt.AlignHCenter or -alignment == QtCore.Qt.AlignJustify) +assert( alignment == (alignment & int(QtCore.Qt.AlignHorizontal_Mask | QtCore.Qt.AlignVertical_Mask))) # General Purpose roles that should return a QColor variant = self.model.data(self.model.index(0,0,QtCore.QModelIndex()), QtCore.Qt.BackgroundColorRole) @@ -313,7 +310,7 @@ c = self.insert.pop() assert(c['parent'] == parent) assert(c['oldSize'] + (end - start + 1) == self.model.rowCount(parent)) -assert(c['last'] == self.model.data(model.index(start-1, 0, c['parent']))) +assert(c['last'] == self.model.data(self.model.index(start-1, 0, c['parent']))) # if c['next'] != self.model.data(model.index(end+1, 0, c['parent'])): # qDebug << start << end @@ -330,19 +327,19 @@ c = {} c['parent'] = parent c['oldSize'] = self.model.rowCount(parent) -c['last'] = self.model.data(model.index(start-1, 0, parent)) -c['next'] = self.model.data(model.index(end+1, 0, parent)) -remove.append(c) +c['last'] = self.model.data(self.model.index(start-1, 0, parent)) +c['next'] = self.model.data(self.model.index(end+1, 0, parent)) +self.remove.append(c) def rowsRemoved(self, parent, start, end): """ Confirm that what was said was going to happen actually did """ -c = remove.pop() +c = self.remove.pop() assert(c['parent'] == parent) assert(c['oldSize'] - (end - start + 1) == self.model.rowCount(parent)) -assert(c['last'] == self.model.data(model.index(start-1, 0, c['parent']))) -assert(c['next'] == self.model.data(model.index(start, 0, c['parent']))) +assert(c['last'] == self.model.data(self.model.index(start-1, 0, c['parent']))) +assert(c['next'] == self.model.data(self.model.index(start, 0, c['parent']))) def checkChildren(self, parent, depth = 0): """ ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Reporting Bugs in PyQt/Qt
On Montag 29 November 2010, Ian wrote: > Having chased down the definition of the role - not in the > class or method, and not linked from either location http://doc.qt.nokia.com/4.7/qabstractitemmodel.html#data with a note: "See also" http://doc.qt.nokia.com/4.7/qt.html#ItemDataRole-enum there you can read Each item in the model has a set of data elements associated with it, each with its own role. The roles are used by the view to indicate to the model which type of data it needs. Custom models should return data in these types. that seems quite clear to me. -- Wolfgang ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] QSqlTableModel.rowCount bug? (and still need infor for beforeInsert)
On Freitag 03 Dezember 2010, KONTRA, Gergely wrote: > Hi all! > > I suspect QSqlTableModel.rowCount cannot return numbers above > 256. rowCount is not the number of rows in the table but in the model, AFAIK. Use fetchMore() to load more. > And can somebody tell me why this code is this painfully slooow? you execute 300 transactions. If you use db.transaction() after db.open() and db.commit() after model.submitAll(), this is only one transaction and much faster. -- Wolfgang ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] QSqlTableModel.rowCount bug? (and still need infor for beforeInsert)
On Freitag 03 Dezember 2010, Andreas Pakulat wrote: > It also doesn't mention that its based on > QSqlQueryModel::rowCount(). That one however does explain > what it returns in its API docs. So it seems like your DB is > at fault, as its not able to return the complete size of the > query. You are right. The Qt SQLITE driver returns False for hasFeature(QSqlDriver.QuerySize) -- Wolfgang ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] bug: QProcessEnvironment insert failing
On Freitag 10 Dezember 2010, Scott Ballard wrote: > The insert method of QProcessEnvironment overwrites the > environment variable instead of inserting into it. according to the manual, this is correct. Inserts the environment variable of name name and contents value into this QProcessEnvironment object. If that variable already existed, it is replaced by the new value. -- Wolfgang ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] segfault, from qt or pyqt?
On Donnerstag 16 Dezember 2010, Hans-Peter Jansen wrote: > > I've just checked, every Qt lib on my system has version > > 4:4.6.3-4 (same as libqt4-dbg) > > Sorry, my fault. It looks like you're missing the PyQt debug > symbols. Ubuntu has a problem - it installs the PyQt debug symbols in the wrong place. Maybe Debian is similar. https://bugs.launchpad.net/bugs/682874 -- Wolfgang ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] vertical alignment of richtext in a table view
On Dienstag 07 September 2010, Mark Summerfield wrote: > > > The offset you need might be made up of the > > > option.decorationSize's width; not sure about the height > > > offset. > > > > > > > > decorationSize is (16,16) - that does not explain it. > > Then I'm not sure. Could try experimenting with the label's > indent, margin, and frameWidth. now I found the problem. This misplaces the text: class RichTextColumnDelegate(QStyledItemDelegate): label = QLabel() def paint(self, painter, option, index): ... self.label.render(painter, option.rect.topLeft()) I have to do: painter.save() painter.translate(option.rect.topLeft()) self.label.render(painter) painter.restore() -- Wolfgang ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] 2 Updates for the modeltest in PyQt4
On Sonntag 20 Februar 2011, Andreas Pakulat wrote: > I didn't test yet against an actual model, so might have done > something wrong in porting. yep. lists have no add, it is append I didn't test either but pylint did Where do you maintain modeltest.py? I got it from http://bazaar.launchpad.net/~bzr/ubuntu/maverick/qbzr/bzr- ppa/annotate/head:/lib/tests/modeltest.py I made a few bug fixes and I believe I mailed them back to the author but now that I check again not all of them made it in, there are still some self. missing in front of model.* also, checking values for TextAlignmentRole is still wrong there: it does not accept ORed values I also changed some things to make pylint happy (my local git commit hook does not let me commit unless pylint is silent) my version, now with your patches: svn cat svn://anonsvn.kde.org/home/kde/trunk/KDE/kdegames/kajongg/src/modeltest.py there also is a modeltest.py from riverbank in contrib/pymodeltest but it has a lot of missing self and does not contain your patches. your paths look like you got it from somewere else again: tests/modeltest/modeltest.py so I know about three different copies where I believe mine has less bugs than the others, and you seem to be patching a forth copy -- Wolfgang ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] 2 Updates for the modeltest in PyQt4
On Montag 21 Februar 2011, Andreas Pakulat wrote: > Now did a closer look at the diff between that version of > mine, the attached 3 patches (one is the add vs. append > change) contain the changes. > > > I made a few bug fixes and I believe I mailed them back to > > the author but now that I check again not all of them made > > it in, there are still some self. missing in front of > > model.* > > Couldn't find any of those, just a self. missing in front of > insert. in rowsAboutToBeInserted and rowsInserted, rowsAboutToBeRemoved and rowsRemoved, several places similar to self.model.data(model.index(... that should be self.model.index > > also, checking values for TextAlignmentRole is still wrong > > there: it does not accept ORed values > > Can you elaborate on this? diff between launchpad.net file and mine: -assert( alignment == QtCore.Qt.AlignLeft or -alignment == QtCore.Qt.AlignRight or -alignment == QtCore.Qt.AlignHCenter or -alignment == QtCore.Qt.AlignJustify) +assert( alignment == (alignment & int(QtCore.Qt.AlignHorizontal_Mask | QtCore.Qt.AlignVertical_Mask))) and c++: Q_ASSERT ( alignment == ( alignment & ( Qt::AlignHorizontal_Mask | Qt::AlignVertical_Mask ) ) ); the launchpad.net version would not accept Qt.AlignLeft|Qt.AlignVCenter the C++ version and mine do. > > I also changed some things to make pylint happy > > (my local git commit hook does not let me commit unless > > pylint is silent) > > Thats probably all those name-changes and line-breaks etc? yes. And whitespace changes and some docstrings. Maybe it is easier to look at my single commits for spotting relevant differences. > There's one change that I don't quite understand though. Its > the "Check that we can get back our real parent", your > version does: > > parentIdx = self.model.parent( index ) > assert( parentIdx.internalId() == parent.internalId() ) > assert( parentIdx.row() == parent.row() ) > > while the PyQt version just compares the index against the > stored one. Do you have any idea why that was done in qbzr > (the log message there is less than useful). I have no idea. In Kajongg I have an editable treeview and adding assert(self.model.parent(index) == parent) passes (just tried). You'll have to ask the author -- Wolfgang ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] configure.py on windows
I am using the kde-windows emerge tool for building pyqt (msv2010 compiler), and I am building everything in Debug mode only. No pyqt previously installed. For that environment, PyQt-win-gpl-4.8.3/configure.py needs some changes: 1. configure.py --debug should use the debug makefile qtdirs.mk.Debug because the release makefile qtdirs.mk is looking for qtmain.lib while only qtmaind.lib is installed 2. make target "release" (or "debug") only makes nmake generate an empty directory "release" or "debug", but if I do not define the target it works. But I patched it only for the debug target - because I tested only that. 3. the exe_file (qtdirs.exe) will be located in the debug directory, not in the release directory are those fixes correct or did I misunderstand something? --- configure.py2011-03-20 00:01:18.427835900 +0100 +++ /tmp/configure.py 2011-03-20 00:02:13.522375001 +0100 @@ -1913,8 +1913,11 @@ qmake_args = fix_qmake_args("-o " + make_file) if sys.platform == 'win32': -exe_file = os.path.join("release", app + ".exe") -make_target = " release" +if sys.platform == 'win32' and opts.debug: +exe_file = os.path.join("debug", app + ".exe") +else: +exe_file = os.path.join("release", app + ".exe") +make_target = " release" elif sys.platform == "darwin": exe_file = os.path.join(app + ".app", "Contents", "MacOS", app) else: @@ -2043,6 +2046,8 @@ remove_file(make_file) run_command("%s %s %s" % (opts.qmake, qmake_args, pro_file)) +if sys.platform == 'win32' and opts.debug: +make_file += '.Debug' if not os.access(make_file, os.F_OK): sipconfig.error("%s failed to create a makefile. %s" % (opts.qmake, MSG_CHECK_QMAKE)) -- Wolfgang ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] distinguish / enable / disable multiple pointer devices
On Freitag 25 März 2011, Gelonida wrote: > I have a PC (Windows) with a mouse, a touch screen and a > graphics tablet. > > > Is there any way to know with which device a widget was > clicked? something like QKeyEvent, QMouseEvent, QTabletEvent, QTouchEvent and QWheelEvent? class MyWidget(QWidget): ... def mousePressEvent(self, event): if event.type() == QEvent.TabletPress: print '%s clicked with Tablet' % self.objectName() It would be more difficult to differentiate between two mice -- Wolfgang ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] qtreewidget only printing first character of my strings
On Donnerstag 21 April 2011, Jason Rahm wrote: > If I uncomment my print statements, each string is printed as > expected, but in the QTreeWidget, I only get the first > character: I think QTreeWidgetItem expects a string list, not a string. Maybe [x] instead of x works better? -- Wolfgang ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Synchronized scrolling between two tables
Am Dienstag, 1. November 2011, 14:02:48 schrieb Nader Abedrabbo: > What I would like though is a synchronized scrolling of the two tables, i.e. > if I scroll the first table, then the second table should scroll to the > same view (same row level) as the first table. > > Is that possible? yes. Have a look at classes ScoreViewLeft, ScoreViewRight and ScoreTable in kajongg http://websvn.kde.org/trunk/KDE/kdegames/kajongg/src/scoring.py?view=markup but I do not see the need for two tables in your case, I would try to use one single QTableView. Initialize the calculated fields to empty and after having calculated them, refresh the view. you do not even need a calculate button. If your calculation really needs some time, you can put the calculation into a separate thread and automatically update the view when a field has been calculcated. -- Wolfgang ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Synchronized scrolling between two tables
Am Mittwoch, 2. November 2011, 06:23:36 schrieb Nader Abedrabbo: > If their is a way to disable certain columns in a table from being selected, > I would appreciate if you can guide me to it. you can define you own model, deriving from a Qt standard model, and override flags(). In the link I gave you there is a file rulesetselector.py which defines a tree view where some items can be edited in different ways (combobox, text, numbers, checkboxes). Your table view should be easier to implement. def flags(self, index): # pylint: disable=R0201 """tell the view what it can do with this item""" if not index.isValid(): return Qt.ItemIsEnabled column = index.column() item = index.internalPointer() content = item.rawContent checkable = False if isinstance(content, Ruleset) and column in (0, 3): mayEdit = True elif isinstance(content, Rule): mayEdit = column in [0, 1, 2, 3] checkable = column == 1 and content.parType is bool else: mayEdit = False mayEdit = mayEdit and not isinstance(item.ruleset(), PredefinedRuleset) result = Qt.ItemIsEnabled | Qt.ItemIsSelectable if mayEdit: result |= Qt.ItemIsEditable if checkable: result |= Qt.ItemIsUserCheckable return result ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] accessing variables of class
Am Donnerstag, 10. Mai 2012, 22:41:06 schrieb Enes Albay: > class C(QtGui.QPushButton): > > def __init__(self, parent, letter): > self.clicked.connect(self.handleLetter) > > def handleLetter(self): > > > > I want to do that: > > lineEdit.setText("bla bla")---> this is in class A class B(QtGui.QWidget): def setupUI(self): self.c = C() self.c.clicked.connect(self.c.handleLetter) but I would probably move handleLetter to class B -- Wolfgang ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] accessing variables of class
Am Freitag, 11. Mai 2012, 16:12:18 schrieb Enes Albay: > Thanks for reply. But, unfortunately, it doesn't solve my problem. it might be helpful if you post a complete runnable example for the problem. that would also tell us if your class C calls __init__ for QPushButton - my favourite guess for now -- Wolfgang ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] accessing variables of class
Am Freitag, 11. Mai 2012, 18:18:18 schrieb Enes Albay: > self.clicked.connect(A.handleLetter) > AttributeError: 'function' object has no attribute '__pyqtSignature__' is A a class or an instance? It should be an instance. conventionally instance names should not start uppercase -- Wolfgang ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] toPyObject is undocumented
http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qvariant.html#toPyObject says nothing about what it does. I just found out it alway returns python long even for small integers. Is that intended or a bug? ii python-qt4 4.9.1-2ubuntu1 Python bindings for Qt4 -- Wolfgang ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] model test
On Friday 14 December 2012 08:38:37 José M. Rodriguez Bacallao wrote: > I have tested the modeltest that came with pyqt4 in my Archlinux > installation (4.9.5) but it doesn't seen to work. Any suggestions? there are several versions floating around. one of them (IMHO the best maintaned one) is part of the kajongg game git clone git://anongit.kde.org/kajongg if you start it with --debug=modelTest all model usage will go thru modeltest -- Wolfgang ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] model test
On Friday 14 December 2012 11:10:51 José M. Rodriguez Bacallao wrote: > I downloaded and put it in my test but this model test is made for API v1 > not API v2, my model use API v2 for QVariant, any suggestions? last time I tried I was not able to make the conversion to v2 because PyKDE4 produced segfaults with v2. The bug report is still open. But when that is fixed, I will certainly try again, including modeltest. https://bugs.kde.org/show_bug.cgi?id=253123 -- Wolfgang ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Compacting long file names or strings
Am Mittwoch, 16. Januar 2013, 09:54:43 schrieb Timothy W. Grove: > Suppose I have a long file name such as "C:\Users\Public\Videos\Sample > Videos\Wildlife.wmv" that I want to display on a button but there isn't > enough room to display the entire name. I want to compact it down to, > say, "C:\Users\...\Wildlife.wmv". I'm pretty sure that I've seen a > method somwhere which will already do this; I just can't remember > where... Does this ring any bells with anyone??? https://qt-project.org/doc/qt-4.8/qfontmetrics.html#elidedText -- Wolfgang ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt