[PyQt] Installing PyOpenGL
Since it took me such a long while to get just the proper versions of Python/Qt/PyQt installed (to sync with Maya 2011), I thought it might be wise to ask beforehand,... Apparently I need to install PyOpenGL,would doing so conflict with, or disable, or modify,etcmy existing installation of Python, Qt, and/or PyQt ? Any words of wisdom most greatly appreciated... Many Thanks, Btw,...does Qt have any graphics/framebuffer capture ability ? ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Question about Sort/Filter behaviour
Hi All, Before asking this question, I did side-by-side testing and confirmation of the sorting results in both the "Basic" and "Custom" examples... Even compared the C++ vs Python generated code, same results... I also checked this on Pete's newly posted custom example.. The observation is this...it appears that typing text into the pattern line generates a behaviour that is *always* regExp behaviour... For example,...supposed I set filterColumn to "Date" filterSyntax to "Wildcard" and finally, in filterPattern, I type 1/* (with no quotes) I would expect to get a view returned with with all the January dates...but I get nothing... If I remove the slash (/), leaving 1*, I get everything, or better said I get the behaviour of regExp,if you switch filterSyntax to "regular expression", you'll get the same results... Another example...set filterColumn to "Date" Type "12:" (no quote) into filterPattern. Now keep switching filterSyntax from "regExp", "Wildcard", and "Fixed String", and every time you get the same output... There are other examples I can provide too There appears to be something odd going on here...at the very least, it doesn't appear to conform to Unix-like standard conventions of regularExpression and/or Wildcard interpretation... Is it just that the "Date" data is set up odd? I tried a similar example on the "Sender" column, but get same kind of results... Lastly,...I set filterColumn to "Subject" filterPattern to "Sports" (again , no quotes) sequencing thru filterSyntax,going from regExp, to Wildcard, to Fixed String, I always get the same output... At least on "Fixed String", I would expect to get 1 returned record, but it's behaving like it's a regExp,...ignoring the "RE: etc" and the "AW: etc" non-matching cases... Does this strike anyone else as odd? or am I just going crazy?..lol Thanks, ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] About dimensions of QAbstractTableModel
On 29.11.10 23:03:10, Vicent Mas wrote: > On 2010-11-29 Andreas Pakulat said: > > On 29.11.10 18:48:26, Vicent Mas wrote: > > > 2010/11/28 Andreas Pakulat : > > > > On 27.11.10 21:27:55, Ian wrote: > > One such thing is that rowCount can be used > > to implement hasChildren, which is what is being done in the default > > implementations. In such a case rowCount is called with an invalid index > > to get the toplevel rowcount. Then when the view wants to find out > > wether an index has children its again called with the valid top-level > > index. In such a case a table and list model wants to make sure to > > return 0 as it has no childrens. This detail is actually also mentioned > > in the API docs for QAbstractItemView::rowCount() as tip. > > > > Indeed that's a very interesting info. But for table models I think that > hasChildren is not meaningful. One can overwrite it without calling rowCount > and then use safely the approach used in the Summerfield's book that I > mention > in my previous mail. I know that Qt api docs recommend something different, > but > the Summerfield's approach is simpler and it just works. I don't know Marks book, but I do know that his material is high quality. Sure for a simple example to learn the basics returning a static number regardless of the parent item passed in is fine. Its easier to understand for beginners, but that doesn't mean its correct. And once your model gets more complicated or you use it for different views you'll eventually run into behavioural weirdness. At that point you should verify that your model works sanely (according to what Qt's itemviews define as sane, which may not be the same as the definition of a human brain ;). Best/easiest way to do that is adding the mentioned modeltest to your model and run your app. One of the things that it'll instantly assert on is returning non-0 amount of rows for a valid parent but no index/data for it. Andreas -- Don't Worry, Be Happy. -- Meher Baba ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Reporting Bugs in PyQt/Qt
On 29.11.10 21:05:43, Ian wrote: > Hi Andreas, > Thank you for the pointer. > > I have just googled and found the documentation that mentions this. > It is not in the > class I am using, nor in the method I am using, nor is it very clear > when I find it. > > Hmmm. > > Having chased down the definition of the role - not in the class or > method, and not linked from either location - You mean you missed the "See also" in http://doc.qt.nokia.com/4.5/qabstractitemmodel.html#headerData? One thing to keep in mind: PyQt is a really thin layer over Qt/C++, so if the PyQt docs seem lacking, just look it up in the Qt api docs. > then it does become a bit clearer. As a noob I had thought that I am > only displaying, so why does the model > call for anything other than display role? Because display'ing takes a lot more than just getting a string to show... And the view doesn't know you're just displaying, it needs to be ready to also edit, tooltip (which is display too) and size things properly. > There are many references to an example which might have helped. This is at > > http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/itemviews-simpletreemodel.html > > This gives a 404. Double H. I'd expect the sample to be part of the PyQt4 distribution (at least the sources). > So. In my first week with Python, PyQt and Qt I have: > a) Uncovered more bugs in QT in one week, than I uncovered in all > the software I used in my first 20 years in IT. > > b) Been helped over styles three times twice here - and once in the > Python list - with information > that was very hard to find if you did not know the exact name you > were looking for. If you think so, talk to Nokia to let them know where to improve the documentation. Personally I find the Qt api docs a really good references, I have to deal with a much more crappy stuff on a daily basis. Same goes to the Qt examples (and the PyQt ones which are mostly python versions of the C++ ones). > Conclusion - super people, shame about the documentation, shame on Qt. > > Have I just hit a bad class in QAbstractTableModel - or is all Qt as buggy? So far there's only a single bug in this thread (and I didn't quite understand your description so I'm not even sure about that) and thats the sorting-thing. Everything else is not a Qt bug, but bugs in your code. Andreas -- Abandon the search for Truth; settle for a good fantasy. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] segmentation faults common when using QWebView
On Monday 29 November 2010, 23:05:57 Brandon Craig Rhodes wrote: > "Hans-Peter Jansen" writes: > > Why not trigger the timer from the loadFinished signal. That way, > > you get the best of both worlds ;) > > That's a good idea! I promise to try it, just as soon as I can stop > the script from giving me a segmentation fault every time that I run > it. :-) > > If no one who has the development version of PyQt4 installed gets the > chance to try my script, then I should have time on Wednesday to sit > down and install the alternate development packages and attempt to > produce a traceback. But before going through all of that I wanted > to see if there was something I was obviously doing wrong with > pointers or something in my code. $ gdb python (gdb) set args qtcrash.py (gdb) run Starting program: /usr/bin/python qtcrash.py [Thread debugging using libthread_db enabled] 4.7.1 snapshot-4.8.2-a935ffc263c2 [New Thread 0xb456bb90 (LWP 10895)] [New Thread 0xb3a43b90 (LWP 10897)] callback1 callback1done div#content > p > a [] div#content > p > a [] div#content > p > a [] div#content > p > a [] div#content > p > a [] div#content > p > a [] div#content > p > a [] div#content > p > a [] div#content > p > a [] div#content > p > a [] div#content > p > a [] div#content > p > a [, ] callback1done div#ferns-info > h2 > a [] div#ferns-info > h2 > a [] Program received signal SIGSEGV, Segmentation fault. QCoreApplication::postEvent (receiver=0x8218f00, event=0x8304bd0, priority=0) at kernel/qcoreapplication.cpp:1133 1133QThreadData *data = *pdata; Current language: auto; currently c++ (gdb) bt #0 QCoreApplication::postEvent (receiver=0x8218f00, event=0x8304bd0, priority=0) at kernel/qcoreapplication.cpp:1133 #1 0xb7811eec in QCoreApplication::postEvent (receiver=0x8218f00, event=0x8304bd0) at kernel/qcoreapplication.cpp:1094 #2 0xb7820dd7 in QObject::deleteLater (this=0x8218f00) at kernel/qobject.cpp:2123 #3 0xb55e2203 in WebCore::QNetworkReplyHandler::finish() () from /usr/lib/libQtWebKit.so.4 #4 0xb55e2848 in WebCore::QNetworkReplyHandler::qt_metacall(QMetaObject::Call, int, void**) () from /usr/lib/libQtWebKit.so.4 #5 0xb7815215 in QMetaObject::metacall (object=0x8218f00, cl=QMetaObject::InvokeMetaMethod, idx=5, argv=0xbfffdc88) at kernel/qmetaobject.cpp:237 #6 0xb7827e93 in QMetaObject::activate (sender=0x8218f00, m=0xb4b3b46c, local_signal_index=1, argv=0x0) at kernel/qobject.cpp:3272 #7 0xb4af8917 in QNetworkReply::finished (this=0x8218f00) at .moc/release-shared/moc_qnetworkreply.cpp:152 #8 0xb4a86eff in QNetworkReplyImplPrivate::finished (this=0x81fd248) at access/qnetworkreplyimpl.cpp:657 #9 0xb4a6a810 in QNetworkAccessBackend::finished (this=0x81fd190) at access/qnetworkaccessbackend.cpp:309 #10 0xb4a712f1 in QNetworkAccessHttpBackend::finished (this=0x81fd190) at access/qnetworkaccesshttpbackend.cpp:338 #11 0xb4a718e4 in QNetworkAccessHttpBackend::replyFinished (this=0x81fd190) at access/qnetworkaccesshttpbackend.cpp:773 #12 0xb4a86c49 in QNetworkReplyImplPrivate::handleNotifications (this=0x81fd248) at access/qnetworkreplyimpl.cpp:367 #13 0xb4a86ce6 in QNetworkReplyImpl::event (this=0x8218f00, e=0x8207550) at access/qnetworkreplyimpl.cpp:867 #14 0xb631ce6c in QApplicationPrivate::notify_helper (this=0x816a6c8, receiver=0x8218f00, e=0x8207550) at kernel/qapplication.cpp:4445 #15 0xb6327786 in QApplication::notify (this=0x812bba8, receiver=0x8218f00, e=0x8207550) at kernel/qapplication.cpp:3845 #16 0xb724902e in sipQApplication::notify (this=0x812bba8, a0=0x8218f00, a1=0x8207550) at QtGui/sipQtGuiQApplication.cpp:297 #17 0xb780f33b in QCoreApplication::notifyInternal (this=0x812bba8, receiver=0x8218f00, event=0x8207550) at kernel/qcoreapplication.cpp:732 #18 0xb78121d8 in QCoreApplicationPrivate::sendPostedEvents (receiver=0x0, event_type=0, data=0x816a7b0) at kernel/qcoreapplication.h:215 #19 0xb781236d in QCoreApplication::sendPostedEvents (receiver=0x0, event_type=0) at kernel/qcoreapplication.cpp:1266 #20 0xb783ee64 in postEventSourceDispatch (s=0x8184110) at kernel/qcoreapplication.h:220 #21 0xb7516998 in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0 #22 0xb751a203 in g_main_context_iterate () from /usr/lib/libglib-2.0.so.0 #23 0xb751a388 in g_main_context_iteration () from /usr/lib/libglib-2.0.so.0 #24 0xb783e971 in QEventDispatcherGlib::processEvents (this=0x8181e38, flags={i = -1073748792}) I've added some debug calls to prove my claim, and as you can see, it crashes in callback2 now after my modifications (that wait for callback1 to finish). Hence, it suffers from the same problem as it doesn't wait there for the load finishing again.. Pete qtcrash.py Description: application/python ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] segmentation faults common when using QWebView
"Hans-Peter Jansen" writes: > Why not trigger the timer from the loadFinished signal. That way, you > get the best of both worlds ;) That's a good idea! I promise to try it, just as soon as I can stop the script from giving me a segmentation fault every time that I run it. :-) If no one who has the development version of PyQt4 installed gets the chance to try my script, then I should have time on Wednesday to sit down and install the alternate development packages and attempt to produce a traceback. But before going through all of that I wanted to see if there was something I was obviously doing wrong with pointers or something in my code. -- Brandon Craig Rhodes bran...@rhodesmill.org http://rhodesmill.org/brandon ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] About dimensions of QAbstractTableModel
On 2010-11-29 Andreas Pakulat said: > On 29.11.10 18:48:26, Vicent Mas wrote: > > 2010/11/28 Andreas Pakulat : > > > On 27.11.10 21:27:55, Ian wrote: > > > > > > [...] > > > > > >> def rowCount(self, parent = None): > > >> ''' return No of rows of data. parent is a QModelIndex ''' > > >> return len(self.view) > > > > > > This is wrong, even for table models you have to take care to return > > > the right number of rows depending on the parent. That means if your > > > model gets asked for the rowCount with a valid parent, you want to > > > return 0 (as you don't have childs under any of your rows). So check > > > for parent.isValid(). > > > > > >> def columnCount(self, parent = None): > > >> ''' return number of columns. parent = QModelIndex() > > >> > > >>id, name, cubref, address, town, contacts > > >> > > >> ''' > > >> return 6 > > > > > > Basically the same here as above, though I think this is not quite as > > > critical. > > > > Hi Andreas, > > > > Are you sure about this? Does it mean that the example given in the > > page 428 of Summerfield's book "Rapid GUI Programming with Python and Qt" > > is wrong? > > Also I find misleading the Qt documentation regarding this subject > > (right now I can only have a look to the Qt-6 docs). On one side the > > QAbstractItemModel.rowCount documentation agrees with you (or > > vice versa :-). But reading the "Model Subclassing Reference" page, > > > section "Read-only access" one can see: > I'm not sure what you're trying to express with the quote, > but as I said > the Qt api docs are really lacking in-depth information about the exact > details of the contract that QAbstractItemModel and the View/Delegate > classes expected to be hold. I completely agree. > One such thing is that rowCount can be used > to implement hasChildren, which is what is being done in the default > implementations. In such a case rowCount is called with an invalid index > to get the toplevel rowcount. Then when the view wants to find out > wether an index has children its again called with the valid top-level > index. In such a case a table and list model wants to make sure to > return 0 as it has no childrens. This detail is actually also mentioned > in the API docs for QAbstractItemView::rowCount() as tip. > Indeed that's a very interesting info. But for table models I think that hasChildren is not meaningful. One can overwrite it without calling rowCount and then use safely the approach used in the Summerfield's book that I mention in my previous mail. I know that Qt api docs recommend something different, but the Summerfield's approach is simpler and it just works. > Anyway, about the columnCount. That one is AFAIK not as problematic > because there's no view that actually supports different amounts of > columns depending on the tree hierarchy. Hence its usually ok to return > a static number from this function. > > To find out what exactly goes wrong in your case a small runnable > example is necessary, IIRC your sample code had additional dependencies > on other software and sample data to provide something useful. You > should try with some static data first. > I've no sent any sample code (I'm not Ian but Vicent :-). I'm just reading the mailing list and trying to improve my understanding of models and views. Vicent :: Share what you know, learn what you don't signature.asc Description: This is a digitally signed message part. ___ 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] Reporting Bugs in PyQt/Qt
On 29/11/2010 19:21, Andreas Pakulat wrote: On 29.11.10 18:44:58, Ian wrote: On 29/11/2010 13:09, Andreas Pakulat wrote: 4) My table has exactly 5 columns of data - ['Name','Ref','Street','Town','Contacts']. If I return 5 from columnCount() then I don't get any headers! If I return 6 then the headers appear - and include an empty column on the right. Anyone know a work-round for this? Post a small runnable example that reproduces this, for example by modifying one of the examples coming with PyQt. Andreas See http://homepage.ntlworld.com/ian.hobson/demo.py This demonstrates two of the errors. After opening, the icon in the first column shows "Ascending" and a click will convert it to "Descending", leaving the sort in "Ascending". Click away and any other column works correctly. Click back to first column and it now works correctly. Can't say anything about this error. If you edit line 50/51 as per comments, you can return the correct value from columnCount() and the headers do not appear (which makes sorting difficult). But this one is caused because you don't take care of the role parameter in headerData. If you only return something for Qt.DisplayRole it works. I can't tell you why this is the case or why it works when adding +1 to the columnCount. That would need some digging into the itemview code in Qt. Andreas Hi Andreas, Thank you for the pointer. I have just googled and found the documentation that mentions this. It is not in the class I am using, nor in the method I am using, nor is it very clear when I find it. Hmmm. Having chased down the definition of the role - not in the class or method, and not linked from either location - then it does become a bit clearer. As a noob I had thought that I am only displaying, so why does the model call for anything other than display role? There are many references to an example which might have helped. This is at http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/itemviews-simpletreemodel.html This gives a 404. Double H. So. In my first week with Python, PyQt and Qt I have: a) Uncovered more bugs in QT in one week, than I uncovered in all the software I used in my first 20 years in IT. b) Been helped over styles three times twice here - and once in the Python list - with information that was very hard to find if you did not know the exact name you were looking for. Conclusion - super people, shame about the documentation, shame on Qt. Have I just hit a bad class in QAbstractTableModel - or is all Qt as buggy? Regards. - And thanks. Ian ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Strange crash with pan on qtghraphichview
On Monday 29 November 2010, 18:53:55 Matteo Boscolo wrote: > Hi All, > I got some strange crash in my qt open source application PythonCAD. > > I have implemented QGraphicsView and QGraphicsScene to render the > line arc ellipse .. of my application. > Randomly I have some crash from the qt library and I can't make any > debug on it because the crash is not on the python code, and no error > is raised from the framework, I have just a crash and the application > goes down > > Can anybody help me on this issue ? The first step would be running your app under gdb control. It boils down to installing the debug packages of Qt, python, sip and PyQt at least, and then: $ gdb python (gdb) set args qtcrash.py (gdb) run Starting program: /usr/bin/python qtcrash.py [Thread debugging using libthread_db enabled] [New Thread 0xb456bb90 (LWP 10895)] [New Thread 0xb3a43b90 (LWP 10897)] Program received signal SIGSEGV, Segmentation fault. QCoreApplication::postEvent (receiver=0x8218f00, event=0x8304bd0, priority=0) at kernel/qcoreapplication.cpp:1133 1133QThreadData *data = *pdata; Current language: auto; currently c++ (gdb) bt #0 QCoreApplication::postEvent (receiver=0x8218f00, event=0x8304bd0, priority=0) at kernel/qcoreapplication.cpp:1133 #1 0xb7811eec in QCoreApplication::postEvent (receiver=0x8218f00, event=0x8304bd0) at kernel/qcoreapplication.cpp:1094 #2 0xb7820dd7 in QObject::deleteLater (this=0x8218f00) at kernel/qobject.cpp:2123 #3 0xb55e2203 in WebCore::QNetworkReplyHandler::finish() () from /usr/lib/libQtWebKit.so.4 #4 0xb55e2848 in WebCore::QNetworkReplyHandler::qt_metacall(QMetaObject::Call, int, void**) () from /usr/lib/libQtWebKit.so.4 #5 0xb7815215 in QMetaObject::metacall (object=0x8218f00, cl=QMetaObject::InvokeMetaMethod, idx=5, argv=0xbfffdc88) at kernel/qmetaobject.cpp:237 #6 0xb7827e93 in QMetaObject::activate (sender=0x8218f00, m=0xb4b3b46c, local_signal_index=1, argv=0x0) at kernel/qobject.cpp:3272 #7 0xb4af8917 in QNetworkReply::finished (this=0x8218f00) at .moc/release-shared/moc_qnetworkreply.cpp:152 #8 0xb4a86eff in QNetworkReplyImplPrivate::finished (this=0x81fd248) at access/qnetworkreplyimpl.cpp:657 #9 0xb4a6a810 in QNetworkAccessBackend::finished (this=0x81fd190) at access/qnetworkaccessbackend.cpp:309 #10 0xb4a712f1 in QNetworkAccessHttpBackend::finished (this=0x81fd190) at access/qnetworkaccesshttpbackend.cpp:338 #11 0xb4a718e4 in QNetworkAccessHttpBackend::replyFinished (this=0x81fd190) at access/qnetworkaccesshttpbackend.cpp:773 #12 0xb4a86c49 in QNetworkReplyImplPrivate::handleNotifications (this=0x81fd248) at access/qnetworkreplyimpl.cpp:367 #13 0xb4a86ce6 in QNetworkReplyImpl::event (this=0x8218f00, e=0x8207550) at access/qnetworkreplyimpl.cpp:867 Post the backtrace. Pete ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Reporting Bugs in PyQt/Qt
On 29.11.10 18:44:58, Ian wrote: > On 29/11/2010 13:09, Andreas Pakulat wrote: > > > >>4) My table has exactly 5 columns of data - > >>['Name','Ref','Street','Town','Contacts']. > >> > >>If I return 5 from columnCount() then I don't get any headers! If I > >>return 6 then the headers appear - and include an empty column on the > >>right. > >> > >>Anyone know a work-round for this? > >Post a small runnable example that reproduces this, for example by > >modifying one of the examples coming with PyQt. > > > >Andreas > > > See http://homepage.ntlworld.com/ian.hobson/demo.py > > This demonstrates two of the errors. > > After opening, the icon in the first column shows "Ascending" and a > click will convert it > to "Descending", leaving the sort in "Ascending". Click away and > any other column works > correctly. Click back to first column and it now works correctly. Can't say anything about this error. > If you edit line 50/51 as per comments, you can return the correct > value from columnCount() > and the headers do not appear (which makes sorting difficult). But this one is caused because you don't take care of the role parameter in headerData. If you only return something for Qt.DisplayRole it works. I can't tell you why this is the case or why it works when adding +1 to the columnCount. That would need some digging into the itemview code in Qt. Andreas -- You will be reincarnated as a toad; and you will be much happier. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] segmentation faults common when using QWebView
On Monday 29 November 2010, 18:30:39 Brandon Craig Rhodes wrote: > "Hans-Peter Jansen" writes: > > From what I can see, you're missing fundamental concepts of the > > asynchronous nature of QtWebView. You should control your test flow > > with signals, instead of a timer, e.g.: > > > > # you need to wait for finishing the load > > self.webview.loadFinished.connect(self.callback1done) > > That does not work for the web site I am testing, because > "loadFinished" is signaled several seconds before the page is > actually complete - maybe because of how Dojo does things > asynchronously? In any event, I could not find a > "loadWhenDojoCallbacksAreAllFinished" signal, so I went with a timer > loop instead. :-) Why not trigger the timer from the loadFinished signal. That way, you get the best of both worlds ;) Pete ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Reporting Bugs in PyQt/Qt
On 29/11/2010 13:09, Andreas Pakulat wrote: 4) My table has exactly 5 columns of data - ['Name','Ref','Street','Town','Contacts']. If I return 5 from columnCount() then I don't get any headers! If I return 6 then the headers appear - and include an empty column on the right. Anyone know a work-round for this? Post a small runnable example that reproduces this, for example by modifying one of the examples coming with PyQt. Andreas See http://homepage.ntlworld.com/ian.hobson/demo.py This demonstrates two of the errors. After opening, the icon in the first column shows "Ascending" and a click will convert it to "Descending", leaving the sort in "Ascending". Click away and any other column works correctly. Click back to first column and it now works correctly. If you edit line 50/51 as per comments, you can return the correct value from columnCount() and the headers do not appear (which makes sorting difficult). Regards Ian ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] About dimensions of QAbstractTableModel
On 29.11.10 18:48:26, Vicent Mas wrote: > 2010/11/28 Andreas Pakulat : > > On 27.11.10 21:27:55, Ian wrote: > > > [...] > > > >> def rowCount(self, parent = None): > >> ''' return No of rows of data. parent is a QModelIndex ''' > >> return len(self.view) > > > > This is wrong, even for table models you have to take care to return the > > right number of rows depending on the parent. That means if your model > > gets asked for the rowCount with a valid parent, you want to return 0 > > (as you don't have childs under any of your rows). So check for > > parent.isValid(). > > > >> def columnCount(self, parent = None): > >> ''' return number of columns. parent = QModelIndex() > >>id, name, cubref, address, town, contacts > >> ''' > >> return 6 > > > > Basically the same here as above, though I think this is not quite as > > critical. > > > > Hi Andreas, > > Are you sure about this? Does it mean that the example given in the > page 428 of Summerfield's book "Rapid GUI Programming with Python and Qt" is > wrong? > Also I find misleading the Qt documentation regarding this subject > (right now I can only have a look to the Qt-6 docs). On one side the > QAbstractItemModel.rowCount documentation agrees with you (or > vice versa :-). But reading the "Model Subclassing Reference" page, > section "Read-only access" one can see: I'm not sure what you're trying to express with the quote, but as I said the Qt api docs are really lacking in-depth information about the exact details of the contract that QAbstractItemModel and the View/Delegate classes expected to be hold. One such thing is that rowCount can be used to implement hasChildren, which is what is being done in the default implementations. In such a case rowCount is called with an invalid index to get the toplevel rowcount. Then when the view wants to find out wether an index has children its again called with the valid top-level index. In such a case a table and list model wants to make sure to return 0 as it has no childrens. This detail is actually also mentioned in the API docs for QAbstractItemView::rowCount() as tip. Anyway, about the columnCount. That one is AFAIK not as problematic because there's no view that actually supports different amounts of columns depending on the tree hierarchy. Hence its usually ok to return a static number from this function. To find out what exactly goes wrong in your case a small runnable example is necessary, IIRC your sample code had additional dependencies on other software and sample data to provide something useful. You should try with some static data first. Andreas -- Today is National Existential Ennui Awareness Day. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] GTK+ theme and anti-aliased fonts on CentOS 5.5
Almar Klein wrote: > On 27 November 2010 20:49, Rex Dieter wrote: > >> Almar Klein wrote: >> >> > I've build an application using PyQt running in Python 3. I am using >> > CentOS 5.5 (using a virtual box) to build binaries which can be used on >> ... >> > My questions are: >> > - Why is the GTK+ theme not available on CentOS, since it's GNOME? >> >> iirc, rhel5's qt is too old (ie, doesnt include the gtk+ theme which was >> introduced in qt-4.5.x). >> > > Ah sorry, I should've said that I build the latest (well, a few weeks ago) > Qt from source, as well as PyQt. And you built it with -gtkstyle option? -- Rex ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Strange crash with pan on qtghraphichview
Hi All, I got some strange crash in my qt open source application PythonCAD. I have implemented QGraphicsView and QGraphicsScene to render the line arc ellipse .. of my application. Randomly I have some crash from the qt library and I can't make any debug on it because the crash is not on the python code, and no error is raised from the framework, I have just a crash and the application goes down Can anybody help me on this issue ? Regards, Matteo ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] About dimensions of QAbstractTableModel
Hi, originally I posted this question the the long thread "Bugs galore in QAbstractTableModel" but I'm suspicious the question has just been missed because I got no answer and that thread seems now mainly devoted to modtest.py So I've decided to resend my question with a new Subject. I hope I'm not being too impatient. 2010/11/28 Andreas Pakulat : > On 27.11.10 21:27:55, Ian wrote: > [...] > >> def rowCount(self, parent = None): >> ''' return No of rows of data. parent is a QModelIndex ''' >> return len(self.view) > > This is wrong, even for table models you have to take care to return the > right number of rows depending on the parent. That means if your model > gets asked for the rowCount with a valid parent, you want to return 0 > (as you don't have childs under any of your rows). So check for > parent.isValid(). > >> def columnCount(self, parent = None): >> ''' return number of columns. parent = QModelIndex() >>id, name, cubref, address, town, contacts >> ''' >> return 6 > > Basically the same here as above, though I think this is not quite as > critical. > Hi Andreas, Are you sure about this? Does it mean that the example given in the page 428 of Summerfield's book "Rapid GUI Programming with Python and Qt" is wrong? Also I find misleading the Qt documentation regarding this subject (right now I can only have a look to the Qt-6 docs). On one side the QAbstractItemModel.rowCount documentation agrees with you (or vice versa :-). But reading the "Model Subclassing Reference" page, section "Read-only access" one can see: " rowCount() Provides the number of rows of data exposed by the model. These four functions must be implemented in all types of model, including list models (QAbstractListModel subclasses) and table models (QAbstractTableModel subclasses). Additionally, the following functions must be implemented in direct subclasses of QAbstractTableModel and QAbstractItemModel: columnCount() Provides the number of columns of data exposed by the model. List models do not provide this function because it is already implemented in QAbstractListModel. " Sorry if I'm missing something obvious (it wouldn't be the first time that I've issues with the Qt documentation regarding models and views). Vicent :: Share what you know, learn what you don't signature.asc Description: This is a digitally signed message part. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] convert windows app to PyQt Widget
On Monday 29 November 2010, 16:31:17 M Chauhan wrote: > Hello all, > > I have been trying to convert an app launched by windows (for ex. > calc) into a QT Widget. In docs, I found a "find()" command which > should do that. ( > http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qwidget.ht >ml#find ) > > But "find" returns a None. > > Below you will find an example code for calculator app. May be I am > not doing something right. > Any pointers please? (I am using : PyQT 4.7.1, Windows XP, Python > 2.6.4) > > Ex code: > > import os , time, win32gui > from subprocess import Popen > from PyQt4 import QtGui > root_dir = os.environ.get("SystemRoot",r"C:\WINDOWS") > calc = r'%s\System32\calc.exe' % root_dir > Popen(calc) > time.sleep(1) > #Get window handle of calc window > calc_hwnd = win32gui.FindWindow(None, "Calculator") > #Creat QT Application > a = QtGui.QApplication([]) > mainwin = QtGui.QMainWindow() > #Set QT mainwindow as parent of calc window > win32gui.SetParent(calc_hwnd, int(mainwin.winId())) > mainwin.showMaximized() > mainwin.show() > #Convert calc into QT widget > wgt = mainwin.find(calc_hwnd) > #XXX: following print gives "None" > *print type(wgt)* > a.exec_() I wouldn't expect something like this to have a _chance_ to work properly. You might get away with some Active X controls, but embedding arbitrary windows is possible with X11 only (AFAIK). Pete ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] segmentation faults common when using QWebView
"Hans-Peter Jansen" writes: > From what I can see, you're missing fundamental concepts of the > asynchronous nature of QtWebView. You should control your test flow > with signals, instead of a timer, e.g.: > > # you need to wait for finishing the load > self.webview.loadFinished.connect(self.callback1done) That does not work for the web site I am testing, because "loadFinished" is signaled several seconds before the page is actually complete - maybe because of how Dojo does things asynchronously? In any event, I could not find a "loadWhenDojoCallbacksAreAllFinished" signal, so I went with a timer loop instead. :-) -- Brandon Craig Rhodes bran...@rhodesmill.org http://rhodesmill.org/brandon ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] segmentation faults common when using QWebView
On Monday 29 November 2010, 16:54:42 Brandon Craig Rhodes wrote: > I think that there is a bright future in using PyQt4 with a QWebView > object for writing basic web tests, and for web automation. My early > experiments suggest that it is a much simpler and faster solution, > when one needs web page browsing with JavaScript enabled, than a > heavyweight technique like running and remotely controlling a > separate browser process. > > But though my first few page loads and clicks went well, I quickly > found that sites of any complexity would cause my Python script to > crash with a segmentation fault. Many of my early examples were > non-deterministic - the script would sometimes crash, but sometimes > succeed - but I have now found a test script which always crashes, > and that therefore might serve as a good example of this bug here on > the mailing list. > > The script is attached to this email. Its output when I run it > against the PyQt4 shipped with Ubuntu Maverick is this: > > $ python2.6 qtcrash.py > 4.7.0 > 4.7.4 > zsh: segmentation fault python2.6 qtcrash.py > > When I download and install the current PyQt4 snapshot instead, this > is the output: > > $ ./v/bin/python2.6 qtcrash.py > 4.7.0 > snapshot-4.8.2-f509333f6b01 > zsh: segmentation fault ./v/bin/python2.6 qtcrash.py > > Is anyone else able to reproduce this? Where would I get started in > tracking down why this code causes PyQt4 to produce a segmentation > fault? Thanks for any guidance! >From what I can see, you're missing fundamental concepts of the asynchronous nature of QtWebView. You should control your test flow with signals, instead of a timer, e.g.: def callback1(self): self.webview = QtWebKit.QWebView() self.webview.show() self.webview.load(QtCore.QUrl( 'http://ec2-184-73-115-78.compute-1.amazonaws.com/simple/' )) # you need to wait for finishing the load self.webview.loadFinished.connect(self.callback1done) def callback1done(self): self.current_callback = self.callback2 This moves the issue into the next step of course, but I'm sure, you get the idea. Pete ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Bugs galore in QAbstractTableModel???
On Mon, Nov 29, 2010 at 4:35 AM, Wolfgang Rohdewald wrote: > 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 Thanks. http://bitbucket.org/tortoisehg/thg/changeset/c8b88546b90e -- Steve Borho ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] segmentation faults common when using QWebView
I think that there is a bright future in using PyQt4 with a QWebView object for writing basic web tests, and for web automation. My early experiments suggest that it is a much simpler and faster solution, when one needs web page browsing with JavaScript enabled, than a heavyweight technique like running and remotely controlling a separate browser process. But though my first few page loads and clicks went well, I quickly found that sites of any complexity would cause my Python script to crash with a segmentation fault. Many of my early examples were non-deterministic - the script would sometimes crash, but sometimes succeed - but I have now found a test script which always crashes, and that therefore might serve as a good example of this bug here on the mailing list. The script is attached to this email. Its output when I run it against the PyQt4 shipped with Ubuntu Maverick is this: $ python2.6 qtcrash.py 4.7.0 4.7.4 zsh: segmentation fault python2.6 qtcrash.py When I download and install the current PyQt4 snapshot instead, this is the output: $ ./v/bin/python2.6 qtcrash.py 4.7.0 snapshot-4.8.2-f509333f6b01 zsh: segmentation fault ./v/bin/python2.6 qtcrash.py Is anyone else able to reproduce this? Where would I get started in tracking down why this code causes PyQt4 to produce a segmentation fault? Thanks for any guidance! """Routines that actually speak Qt to drive its web views.""" import sys from PyQt4 import QtCore, QtGui, QtWebKit print QtCore.QT_VERSION_STR print QtCore.PYQT_VERSION_STR class SimpleTest(object): def __init__(self): self.current_callback = self.callback1 def step(self): next = self.current_callback() if next is not None: self.current_callback = next def findAll(self, selector): return list(self.webview.page().mainFrame().findAllElements(selector)) def click(self, element): element.evaluateJavaScript( "var event = document.createEvent('MouseEvents');" "event.initEvent('click', true, true);" "this.dispatchEvent(event);" ) def callback1(self): self.webview = QtWebKit.QWebView() self.webview.show() self.webview.load(QtCore.QUrl( 'http://ec2-184-73-115-78.compute-1.amazonaws.com/simple/' )) return self.callback2 def callback2(self): elist = self.findAll('div#content > p > a') if elist: self.click(elist[0]) return self.callback3 def callback3(self): elist = self.findAll('div#ferns-info > h2 > a') if elist: self.click(elist[0]) return self.callback4 def callback4(self): elist = self.findAll('div#lycophytes-info > h2 > a') if elist: self.click(elist[0]) return self.callback5 def callback5(self): pass # The Qt application itself. app = QtGui.QApplication(sys.argv) tester = SimpleTest() timer = QtCore.QTimer() timer.timeout.connect(tester.step) timer.start(50) sys.exit(app.exec_()) -- Brandon Craig Rhodes bran...@rhodesmill.org http://rhodesmill.org/brandon ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] convert windows app to PyQt Widget
Hello all, I have been trying to convert an app launched by windows (for ex. calc) into a QT Widget. In docs, I found a "find()" command which should do that. ( http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qwidget.html#find ) But "find" returns a None. Below you will find an example code for calculator app. May be I am not doing something right. Any pointers please? (I am using : PyQT 4.7.1, Windows XP, Python 2.6.4) Ex code: import os , time, win32gui from subprocess import Popen from PyQt4 import QtGui root_dir = os.environ.get("SystemRoot",r"C:\WINDOWS") calc = r'%s\System32\calc.exe' % root_dir Popen(calc) time.sleep(1) #Get window handle of calc window calc_hwnd = win32gui.FindWindow(None, "Calculator") #Creat QT Application a = QtGui.QApplication([]) mainwin = QtGui.QMainWindow() #Set QT mainwindow as parent of calc window win32gui.SetParent(calc_hwnd, int(mainwin.winId())) mainwin.showMaximized() mainwin.show() #Convert calc into QT widget wgt = mainwin.find(calc_hwnd) #XXX: following print gives "None" *print type(wgt)* a.exec_() Thanks and wishes, Mru ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] fixes for scribble issues
Dear Phil, examples/widgets/scribble.py suffers from a couple of issues at the moment. Most importantly, QtGui.QImageWriter.supportedImageFormats() and QAction.data() return QByteArrays now (with QVariant API 2), resulting in: Traceback (most recent call last): File "./scribble.py", line 317, in window = MainWindow() File "./scribble.py", line 178, in __init__ self.createActions() File "./scribble.py", line 236, in createActions action = QtGui.QAction(text, self, triggered=self.save) TypeError: arguments did not match any overloaded call: QAction(QObject): argument 1 has unexpected type 'QByteArray' QAction(QString, QObject): argument 1 has unexpected type 'QByteArray' QAction(QIcon, QString, QObject): argument 1 has unexpected type 'QByteArray' on start up and Traceback (most recent call last): File "./scribble.py", line 200, in save self.saveFile(fileFormat) File "./scribble.py", line 304, in saveFile "%s Files (*.%s);;All Files (*)" % (fileFormat.upper(), fileFormat)) AttributeError: 'QByteArray' object has no attribute 'upper' Further more, printing (to PDF at least) leads to: QPaintDevice: Cannot destroy paint device that is being painted Speicherzugriffsfehler (gdb) set args ./scribble.py (gdb) run Starting program: /usr/bin/python ./scribble.py [Thread debugging using libthread_db enabled] [New Thread 0xb52c3b90 (LWP 29758)] [New Thread 0xb48ffb90 (LWP 29759)] QPaintDevice: Cannot destroy paint device that is being painted [Thread 0xb52c3b90 (LWP 29758) exited] [Thread 0xb48ffb90 (LWP 29759) exited] Program received signal SIGSEGV, Segmentation fault. 0x0002 in ?? () (gdb) bt #0 0x0002 in ?? () #1 0xb643b668 in ~QPainter (this=0x83dce70) at painting/qpainter.cpp:1504 #2 0xb6fe4010 in release_QPainter (sipCppV=0x83dce70) at QtGui/sipQtGuiQPainter.cpp:5596 #3 0xb6fe406c in dealloc_QPainter (sipSelf=0xb5b9a454) at QtGui/sipQtGuiQPainter.cpp:5607 #4 0xb7fc4f1f in forgetObject (sw=0xb5b9a454) at siplib.c:10001 #5 0xb7fc4fb1 in sipSimpleWrapper_dealloc (self=0xb5b9a454) at siplib.c:9230 #6 0xb7ebb68d in subtype_dealloc (self=0xb5b9a454) at Objects/typeobject.c:1018 #7 0xb7e8d24a in frame_dealloc (f=0x83b355c) at Objects/frameobject.c:417 #8 0xb7ef9bec in PyEval_EvalCodeEx (co=0xb7c39410, globals=0xb7c7702c, locals=0x0, args=0xb5ee73b8, argcount=1, kws=0x0, kwcount=0, defs=0x0, defcount=0, closure=0x0) at Python/ceval.c:2953 #9 0xb7e8ea29 in function_call (func=0xb5ebce64, arg=0xb5ee73ac, kw=0x0) at Objects/funcobject.c:524 #10 0xb7e69c1c in PyObject_Call (func=0xb5ebce64, arg=0xb5ee73ac, kw=0x0) at Objects/abstract.c:2487 #11 0xb7e779fe in instancemethod_call (func=0xb5ebce64, arg=0xb5ee73ac, kw=0x0) at Objects/classobject.c:2579 #12 0xb7e69c1c in PyObject_Call (func=0xb7c276e4, arg=0xb7c5302c, kw=0x0) at Objects/abstract.c:2487 #13 0xb7ef277f in PyEval_CallObjectWithKeywords (func=0xb7c276e4, arg=0xb7c5302c, kw=0x0) at Python/ceval.c:3548 #14 0xb7fcf19f in sip_api_invoke_slot (slot=0x81eed8c, sigargs=0xb5ee71ec) at qtlib.c:203 #15 0xb78f2e8d in PyQtProxy::invokeSlot (sl...@0x81eed8c, qargs=0xbfffd4f0) at qpycore_pyqtproxy.cpp:474 #16 0xb78f2f98 in PyQtProxy::unislot (this=0x81eed70, qargs=0xbfffd4ec) at qpycore_pyqtproxy.cpp:416 #17 0xb78f30d7 in PyQtProxy::qt_metacall (this=0x81eed70, _c=QMetaObject::InvokeMetaMethod, _id=1, _a=0xbfffd4ec) at qpycore_pyqtproxy.cpp:380 #18 0xb7614215 in QMetaObject::metacall (object=0x0, cl=QMetaObject::InvokeMetaMethod, idx=5, argv=0xbfffd4ec) at kernel/qmetaobject.cpp:237 #19 0xb7626e93 in QMetaObject::activate (sender=0x81eec90, m=0xb6c38858, local_signal_index=1, argv=0xbfffd4ec) at kernel/qobject.cpp:3272 #20 0xb62bad89 in QAction::triggered (this=0x81eec90, _t1=false) at .moc/release-shared/moc_qaction.cpp:263 #21 0xb62bc69f in QAction::activate (this=0x81eec90, event=QAction::Trigger) at kernel/qaction.cpp:1257 #22 0xb6786c57 in QMenuPrivate::activateCausedStack (this=0x81f1668, causedsta...@0xbfffd5c8, action=0x81eec90, action_e=QAction::Trigger, self=true) at widgets/qmenu.cpp:993 #23 0xb678cbbb in QMenuPrivate::activateAction (this=0x81f1668, action=0x81eec90, action_e=QAction::Trigger, self=) at widgets/qmenu.cpp:1085 Explicitely end()ing the painter in print_ solved this. While at it, add some obviously missing "self" references to size(). Pete --- ./scribble.py.orig 2010-11-27 04:43:52.0 +0100 +++ ./scribble.py 2010-11-29 15:46:25.707908176 +0100 @@ -66,7 +66,7 @@ class ScribbleArea(QtGui.QWidget): if not loadedImage.load(fileName): return False -newSize = loadedImage.size().expandedTo(size()) +newSize = loadedImage.size().expandedTo(self.size()) self.resizeImage(loadedImage, newSize) self.image = loadedImage self.modified = False @@ -75,7 +75,7 @@ class ScribbleArea(QtGui.QWidget): def saveImage(self, fileName, fileFormat): visibleImage = self.image -
[PyQt] complete webkit examples collection
Hi Phil, hi *, attached are a collection of the webkit examples: domtraversal.py fancybrowser.py formextractor.py framecapture.py googlechat.py previewer.py simpleselector.py A few notes: They demonstrate different aspects in using the webkit, and how javascript code and the webkit object model interact with PyQt code. Most are transcoded 1:1 from their C++ originals. I made a few adjustments in naming the ui files and classes for consistence and in order to not interfere with others. That allows them being kept together in a single folder. fancybrowser.py is a _very_ simple, but funny browser which shows gimmicks like turning images upside down, and modifying the displayed page by removing some elements. The command line program framecapture.py differs from the original in such a way, that it is possible to capture page images from sites like http://spiegel.de correctly (basically an awfully tall page), where the original fails to render everything below a screen height worth of data). simpleselector.py is slightly improved in that it reverts the last action before applying the next. Hence, it is possible to revert any changes by highlighting an empty element. From the statistical department, it's worth to note, that all scripts together with all auxiliary source files (ui, resources) are about the same size as the single jquery module used by fancybrowser! Enjoy, Pete webkit-20101129.tar.bz2 Description: application/tbz ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Reporting Bugs in PyQt/Qt
On 29.11.10 12:42:53, Ian wrote: > 2) When you call setSortingEnabled(True) on a QTreeView the model's > sort routine is called twice. > > No sort is necessary in my use case, because the data is already sorted > correctly. However I would accept a single sort column 0, ascending. > > Besides, sorting should *always* be done in the view and never in the > model. Sorting is a matter of data presentation. A model may have many > views - and each could sort in different orders without interfering with > each other. The view has the data. > > So SortEnable should handle it all - and map the index back, so the data > in the model need not move. If the view needs to know the domain of a > column (numeric, string, character set), then it should ask the model. > > This bug has been reported since PyQt 4.4 - and is still outstanding. Of course, reporting it against PyQt doesn't help, you need to report this to Nokia, unless you can demonstrate that the equivalent C++ code has no such problem. That being said, sorting is supposed to be done through a proxy model these days, i.e. the view doesn't work on the "real" model directly. > 3) When the bug in 2) has finished sorting the data twice, it results in > the header icon being in the wrong sense. Clicking the header continues > to sort the data in the opposite direction to that indicated by the > icon. After clicking to another column and clicking back it does > correct itself. This only effects column 0. Again sounds like a Qt (or style) bug. > - > 4) My table has exactly 5 columns of data - > ['Name','Ref','Street','Town','Contacts']. > > If I return 5 from columnCount() then I don't get any headers! If I > return 6 then the headers appear - and include an empty column on the > right. > > Anyone know a work-round for this? Post a small runnable example that reproduces this, for example by modifying one of the examples coming with PyQt. Andreas -- You have an ambitious nature and may make a name for yourself. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Reporting Bugs in PyQt/Qt
On Mon, 29 Nov 2010 12:42:53 +, Ian wrote: > Hi Everyone > > I have four bugs to report. Where should they be reported? PyQt bugs should be reported on this mailing list. Qt bugs should be reported to Nokia. > 1) The PyQt documentation contains a lot of things like this: at > http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qabstractitemview.html#selectionChanged > > > QAbstractItemView.selectionChanged (self, QItemSelection > (http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qitemselection.html), > > QItemSelection > (http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qitemselection.html)) > > This method is also a Qt slot with the C++ signature void > selectionChanged(const QItemSelection&,const QItemSelection&). > > This slot is called when the selection is changed. The previous > selection (which may be empty), is specified by deselected, and the new > selection by selected. > > > I can guess that "deselected" is one parameter, and "selected" refers to > the other. I cannot tell which is which. > > Suggestion - The title should be the Python def line of the method. The > main text should include a table containing > The parameter name > Its type > if it is optional or mandatory > Its purpose The lack of argument names in the documentation is a bug. > 2) When you call setSortingEnabled(True) on a QTreeView the model's > sort routine is called twice. > > No sort is necessary in my use case, because the data is already sorted > correctly. However I would accept a single sort column 0, ascending. > > Besides, sorting should *always* be done in the view and never in the > model. Sorting is a matter of data presentation. A model may have many > views - and each could sort in different orders without interfering with > each other. The view has the data. > > So SortEnable should handle it all - and map the index back, so the data > in the model need not move. If the view needs to know the domain of a > column (numeric, string, character set), then it should ask the model. > > This bug has been reported since PyQt 4.4 - and is still outstanding. If it's a bug then it's a Qt bug. > 3) When the bug in 2) has finished sorting the data twice, it results in > the header icon being in the wrong sense. Clicking the header continues > to sort the data in the opposite direction to that indicated by the > icon. After clicking to another column and clicking back it does > correct itself. This only effects column 0. This is Qt. > 4) My table has exactly 5 columns of data - > ['Name','Ref','Street','Town','Contacts']. This is Qt. > If I return 5 from columnCount() then I don't get any headers! If I > return 6 then the headers appear - and include an empty column on the > right. > > Anyone know a work-round for this? > > Regards > > Ian Phil ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Reporting Bugs in PyQt/Qt
Hi Everyone I have four bugs to report. Where should they be reported? 1) The PyQt documentation contains a lot of things like this: at http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qabstractitemview.html#selectionChanged QAbstractItemView.selectionChanged (self, QItemSelection (http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qitemselection.html), QItemSelection (http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qitemselection.html)) This method is also a Qt slot with the C++ signature void selectionChanged(const QItemSelection&,const QItemSelection&). This slot is called when the selection is changed. The previous selection (which may be empty), is specified by deselected, and the new selection by selected. I can guess that "deselected" is one parameter, and "selected" refers to the other. I cannot tell which is which. Suggestion - The title should be the Python def line of the method. The main text should include a table containing The parameter name Its type if it is optional or mandatory Its purpose 2) When you call setSortingEnabled(True) on a QTreeView the model's sort routine is called twice. No sort is necessary in my use case, because the data is already sorted correctly. However I would accept a single sort column 0, ascending. Besides, sorting should *always* be done in the view and never in the model. Sorting is a matter of data presentation. A model may have many views - and each could sort in different orders without interfering with each other. The view has the data. So SortEnable should handle it all - and map the index back, so the data in the model need not move. If the view needs to know the domain of a column (numeric, string, character set), then it should ask the model. This bug has been reported since PyQt 4.4 - and is still outstanding. 3) When the bug in 2) has finished sorting the data twice, it results in the header icon being in the wrong sense. Clicking the header continues to sort the data in the opposite direction to that indicated by the icon. After clicking to another column and clicking back it does correct itself. This only effects column 0. - 4) My table has exactly 5 columns of data - ['Name','Ref','Street','Town','Contacts']. If I return 5 from columnCount() then I don't get any headers! If I return 6 then the headers appear - and include an empty column on the right. Anyone know a work-round for this? Regards Ian ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] textedit example
Ping On Thursday 04 November 2010, 23:42:33 Hans-Peter Jansen wrote: > Hi Phil et al., > > since I was "in the mood" last night, here's the textedit example for > the collection. > > This is a simple richtext editor in about 26k code. I'm inclined to > say, it's fullblown, but they did the easy parts only: no page > header/footer setup, no interface for embedding images, nor one to > create/edit tables. > > On the bright side, it has > * the usual font chooser, sizes and attributes > * alignment > * a bunch of different list styles, > * a print preview > in only about 600 LOC! > > One notable inanity: while it saves documents in odt format by > _default_, it cannot read this format back in! That's because an odf > _reader_ is simply missing in Qt. Hence, you can save as odt, open it > in oowriter (where the demo doc looks pretty nice) and save that in > html format again. That one should be readable for textedit again > (didn't test that, though). Phil, wouldn't that fit perfectly in examples/richtext? (it derived from demos/textedit) Pete ___ 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