Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 5

Qt-interest Archive, June 2007
QTableWidget size


Message 1 in thread

Hi,

I have top level widget which has just one child - QTableWidget. I would like to provide such initial size for the top level widget that the table is shown completely (without scrollbars). How can I _after_ populating the QTableWidget with items but _before_ calling show() query for the size of QTableWidget's contents? Then I would use a little bit bigger values of the size to define dimensions of top level widget and show it.

Thanks for your help!

Krzysztof Kobus





      ___________________________________________________________________________________
You snooze, you lose. Get messages ASAP with AutoCheck
in the all-new Yahoo! Mail Beta.
http://advision.webevents.yahoo.com/mailbeta/newmail_html.html

--
 [ signature omitted ] 

Message 2 in thread

I've had the exact same issue in the app I am developing.  Once the 
table was filled, I took the width of each cell in the column + the 
width of the vertical header.  I added the number of columns to account 
for the pixel between each column.  I can do this because we are going 
to stick with a single style.  You'll have to try it with the styles 
you'll be using.

Briefly the code would look something like this:

   myView->resizeColumnToContents(0);

    int w = 0;
    int count = columnCount();
    for (int i = 0; i < count; i++)
        w += myView->columnWidth(i);

    int maxW =
        (w +
        count +
        myView->verticalHeader()->width() +
        myView->verticalScrollBar()->width());

    myView->setMaximumWidth(maxW);
    myView->setMinimumWidth(maxW);

You could do something similar for the height.

HTH,
Susan


Krzysztof Kobus wrote:
> Hi,
>
> I have top level widget which has just one child - QTableWidget. I would like to provide such initial size for the top level widget that the table is shown completely (without scrollbars). How can I _after_ populating the QTableWidget with items but _before_ calling show() query for the size of QTableWidget's contents? Then I would use a little bit bigger values of the size to define dimensions of top level widget and show it.
>
> Thanks for your help!
>
> Krzysztof Kobus
>
>
>
>
>
>       ___________________________________________________________________________________
> You snooze, you lose. Get messages ASAP with AutoCheck
> in the all-new Yahoo! Mail Beta.
> http://advision.webevents.yahoo.com/mailbeta/newmail_html.html
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
>
>   


---

This communication contains confidential information. If you are not the intended recipient please return this email to the sender and delete it from your records.

Diese Nachricht enthält vertrauliche Informationen. Sollten Sie nicht der beabsichtigte Empfänger dieser E-mail sein, senden Sie bitte diese an den Absender zurück und löschen Sie die E-mail aus Ihrem System.

--
 [ signature omitted ]