[Qt-interest] setViewportMargins on QTableView

Davor J. DavorJ at live.com
Thu Feb 4 08:34:40 CET 2010


Thanks for the suggestion André. I think I'll just point this to their 
documentation-team.

Regards,
Davor

"Andre Somers" <andre at familiesomers.nl> wrote in message 
news:4B694DDB.4060302 at familiesomers.nl...
> Davor J. wrote:
>> I am currently trying to set the viewportMargins on QTableView. 
>> Apparently, QTableView calls setViewportMargins() internally, so I have 
>> to adjust it constantly in the resizeEvent() to take effect. In my search 
>> for how to implement it correctly, I read this line from the 
>> QAbstractScrollArea::setViewportMargins reference:
>>
>> "Note that this function is frequently called by QTreeView and 
>> QTableView, so margins must be implemented by QAbstractScrollArea 
>> subclasses. Also, if the subclasses are to be used in item views, they 
>> should not call this function."
>>
>> I do not see how this can be done. How does one subclass 
>> QAbstractScrollArea so it can be used by the QTableView. The member 
>> function is not virtual, so QTreeView will always call 
>> QAbstractScrollArea::setViewportMargins() internally, no matter how I 
>> implement it?
>>
> The way I read that statement, is that you are right in your assessment 
> that it can not be done. What I'd probably do, if I really needed the 
> feature you need, is one of these things:
> 1) modify the Qt source code, and distribute your modified libs with your 
> application. That yields two sub-options:
> 1a) do that in such a way, that it is binairy compatible, and submit the 
> patch to the Trolls and pray that it is accepted,
> 1b) accept that you have just entered a maintance nightmare, and that 
> you'll need to re-apply the patch against every future version of Qt.
> 2) copy the relevant code of Qt over to your own project, and modify it as 
> part of your own project. Depending on your licence and the place where 
> you leave that code (separate lib or really inside the application 
> itself), that may or may not limit the licence options of your own code. A 
> significant downside is that you basically end up in option 1b above 
> again, though this time you only need to keep an eye on that part of the 
> Qt code to see if there are relevant patches for you.
>
> I'm not sure what class exactly calls the setViewportMargins method. If it 
> is QTableView, you may just have to copy that code and adapt it. If it is 
> deeper in the hierarchy, perhaps you'd end up with too much of the Qt code 
> in your own project to get rid of it to your liking. I know, both options 
> suck, but I can't think of another.
>
> André
>
> 





More information about the Qt-interest-old mailing list