[Qt-interest] How do I choose the number of rows that a QListWidget displays?

Justin Noel justin at ics.com
Wed Mar 18 15:31:35 CET 2009


I'm not quite sure what you are looking to do, but one situation that
haven't been covered in this list come to mind:

Qt's Views don't have very intelligent sizeHints and that might be what
you are running into.  You will probably need to subclass
QList[Widget|View] and impl sizeHint() where you add together and return
pixels heights of the rows you want shown. If you make this a dynamic
property be sure to call updateGeometry() after changing the variable
containing the new number of "visible rows" to force a layout re-calc.
Then if every widget gets their size hint and there is no extra space
the in layout then you will have your specified number of rows visible
and if there are more available, a scrollbar will appear. If there is
more or less space available for the layout than the total of the
sizeHints then the usual Qt layout rules apply with regards to Size
Policy and stretch factor.

--Justin

Robert Allan Schwartz wrote:
> You're right, I'm getting a scrollbar. However, in my application, the 
> listwidget is only displaying 3 items total. How can I get it to display 5, 
> or 10, plus the scrollbar?
>
> Thanks,
>
> Robert
>
> ----- Original Message ----- 
> From: "Malyushytsky, Alex" <alex at wai.com>
> To: <qt-interest at trolltech.com>
> Sent: Tuesday, March 17, 2009 5:27 PM
> Subject: Re: [Qt-interest] How do I choose the number of rows that a 
> QListWidget displays?
>
>
> You don't chose.
> It displays everything in the list.
> If list does not fit viewport (basically defined by geometry of 
> QListWidget), scrollbars are displayed.
>
> Alex
>
> ________________________________
> From: qt-interest-bounces at trolltech.com 
> [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Robert Allan 
> Schwartz
> Sent: Tuesday, March 17, 2009 1:57 PM
> To: Scott Aron Bloom
> Cc: qt-interest at trolltech.com
> Subject: Re: [Qt-interest] How do I choose the number of rows that a 
> QListWidget displays?
>
> I asked a different question.
>
> My question is: How do I choose the number of rows that are DISPLAYED, not 
> that are contained.
>
> Thanks,
>
> Robert
>
>
> -------- Original Message --------
> Subject: RE: [Qt-interest] How do I choose the number of rows that a
> QListWidget displays?
> From: "Scott Aron Bloom" <Scott.Bloom at sabgroup.com>
> Date: Tue, March 17, 2009 4:47 pm
> To: "Robert Allan Schwartz" <notbob at tessellation.com>,
> <qt-interest at trolltech.com>
> The number of rows for QListWidget is based on the count in the items that 
> you add..
>
> It changes for every addItem and addItems (or inserItem and deleteItem)
>
> Scott
>
>
> From: Robert Allan Schwartz [mailto:notbob at tessellation.com]
> Sent: Tuesday, March 17, 2009 11:16 AM
> To: qt-interest at trolltech.com; Scott Aron Bloom
> Cc: Robert Allan Schwartz
> Subject: RE: [Qt-interest] How do I choose the number of rows that a 
> QListWidget displays?
>
> Not meaning to be sarcastic, but I did read the docs; had I found the answer 
> there, I would not have posted.
>
> I haven't tried any functions, because I didn't find any functions that 
> looked like they would do what I wanted.
>
> I searched for 'row' in the doc pages for QListWidget and all of its base 
> classes, and did not find what I was looking for.
>
> Thanks,
>
> Robert
>
>
> -------- Original Message --------
> Subject: Re: [Qt-interest] How do I choose the number of rows that a
> QListWidget displays?
> From: "Scott Aron Bloom" <Scott.Bloom at sabgroup.com>
> Date: Tue, March 17, 2009 2:12 pm
> To: <qt-interest at trolltech.com>
> Try reading the docs.
>
> Let us know what functions you have tried..
>
> I would do a search on 'row' in the QListWIdget help
>
> Scott
>
> From: qt-interest-bounces at trolltech.com 
> [<mailto:qt-interest-bounces at trolltech.com>mailto:qt-interest-bounces at trolltech.com] 
> On Behalf Of Robert Allan Schwartz
> Sent: Tuesday, March 17, 2009 11:10 AM
> To: qt-interest at trolltech.com
> Subject: [Qt-interest] How do I choose the number of rows that a QListWidget 
> displays?
>
> Hi All,
>
> Newbie here. This is my first post.
>
> How do I choose the number of rows that a QListWidget displays?
>
> Right now, different QListWidget's display different numbers of rows, and I 
> don't know why.
>
> Thanks,
>
> Robert
> ________________________________
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> <http://lists.trolltech.com/mailman/listinfo/qt-interest>http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>
> ---------------------------------------------------------------------------------------------------
> Weidlinger Associates, Inc. made the following annotations.
>
> "This message and any attachments are solely for the intended recipient and 
> may contain confidential or privileged information. If you are not the 
> intended recipient, any disclosure, copying, use, or distribution of the 
> information included in this message and any attachments is prohibited. If 
> you have received this communication in error, please notify us by reply 
> e-mail and immediately and permanently delete this message and any 
> attachments. Thank you."
>
> "Please consider our environment before printing this email."
>
>
>
> --------------------------------------------------------------------------------
>
>
>   
>> _______________________________________________
>> Qt-interest mailing list
>> Qt-interest at trolltech.com
>> http://lists.trolltech.com/mailman/listinfo/qt-interest
>>
>>     
>
>
> --------------------------------------------------------------------------------
>
>
>
> No virus found in this incoming message.
> Checked by AVG - www.avg.com
> Version: 8.0.237 / Virus Database: 270.11.16/2005 - Release Date: 03/16/09 
> 19:01:00
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>   

-------------- next part --------------
A non-text attachment was scrubbed...
Name: justin.vcf
Type: text/x-vcard
Size: 233 bytes
Desc: not available
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090318/78b41e99/attachment.vcf 


More information about the Qt-interest-old mailing list