Quantcast
Channel: Jobs
Viewing all articles
Browse latest Browse all 18427

How to display a model data in 2 views in different format, say in binary and hexadecimal?

$
0
0
Hi I’m new to both GUI programming and Qt, just having a question and it has confused me for days. I need to display a model in 2 views, but in different format, in details, I have a 2 dimensional array of unsigned char, and want to display them in 2 table, one in binary format, and the other in hexadecimal. The model is derived from the QAbstractTableModel, and I’m using 2 QTableView to display it. I know I can let the model to output a QString in binary or hexadecimal format but that doesn’t meet my requirement to share the same model within 2 views. So I just let the data() function to return a unsigned char directly. I guess a delegate is the right way to get the data rendered properly for each view? but I couldn’t find a document about this, the delegate documents are all about editing data with widgets or graphic displays. I noticed there is a function called displayText() in QStyledItemDelegate, and I tried it and it works (derived 2 new delegates from it and overrided the displayText() functions) . But this function doesn’t exist in QItemDelegate, according to the class reference, QStyledItemDelegate only comes to existance after Qt 4.4, so I guess there must be some other way to do it, in other words I might use the wrong approach. Could anyone give me some advice on this? Thanks

Viewing all articles
Browse latest Browse all 18427

Trending Articles