[PyQt] Trouble implementing a TableView model

Bernard Van Der Stichele Bernard_VanDerStichele at otpp.com
Tue Aug 3 14:52:48 BST 2010


Mark,

Thanks for your suggestion. 

Problem solved by specifying both self.model and self.proxy

Thanks again,
Bernard.





Hi Bernard,

On Tue, 3 Aug 2010 08:09:25 -0400
"Bernard Van Der Stichele" <Bernard_VanDerStichele at otpp.com> wrote:

> A while back, I had asked the group how I could implement a numeical
> sort on a TableWidget.
> Someone kindly showed me how to implement a model, associated with a 
> TableView. The sample code was posted here: 
> http://diotavelli.net/PyQtWiki/Sorting%20numbers%20in%20columns
> 
> I'm having problems implementing this in my app. In this simple
> example, I use Qt Designer to create a MainForm containing a
> TableView (gridView), a LineEdit (queryBox) and a PushButton
> (runQueryBtn). The designer files (.ui and ui_xxx.py) generated
> defines the TableView in a couple of lines - I have not used the
> Designer to change any of the default object properties.
> 
> The problem I have is that the TableView remains blank. I do not 
> understand what I'm missing, as I tried to follow the same workflow
> as provided by the code linked-to above..
> The code works, in that the data I want to display is retrieved from
> a database and I receive no runtime warnings or errors.
> 
> Any help is greatly appreciated... this is probably one of those
> simple newbie errors.
> 
> My application shell is as follows:
[snip]

I've only had the chance for a quick glimpse at your code.

One thought would be to replace

    model

with

    self.model

because I think it might be getting garbage collected. (Or give the
model a parent.)

BTW You might be able to avoid a proxy altogether since you're using
standard items: look up QStandardItemModel.sortRole() &
QStandardItemModel.setSortRole().

[snip]



-- 
Mark Summerfield, Qtrac Ltd, www.qtrac.eu
    C++, Python, Qt, PyQt - training and consultancy
        "Advanced Qt Programming" - ISBN 0321635906
            http://www.qtrac.eu/aqpbook.html






CONFIDENTIALITY WARNING
This e-mail message, including any attachment(s), is confidential. If we sent this communication to you in error, please do not disclose it to anyone else or use the information in it. Please notify the sender of the transmission error and then delete our communication from your system without printing, copying or forwarding it.  Thank you for your co-operation.

AVERTISSEMENT CONCERNANT LE CARACTERE CONFIDENTIEL DE L'INFORMATION

Le present courriel, y compris toute piece qui y est jointe, est confidentiel. Si nous vous avons envoye cette communication par erreur, nous vous prions de ne la divulguer a personne ni a utiliser l’information qu’elle contient. Veuillez informer l’expediteur de l’erreur de transmission et effacer ensuite notre communication de votre systeme sans l’imprimer, ni la copier ni la retransmettre. Nous vous remercions de votre cooperation.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20100803/ea027122/attachment-0001.html>


More information about the PyQt mailing list