QTableWidget: how to stretch columns?



  • Hi, I'd like to know how to stretch a QTableWidget's columns from the designer? thanks.



  • please help.



  • QListWidget doesn't have columns afaik (TextMode). Are you talking about IconMode ? What exactly you want to resize ?



  • [quote author="zeljko" date="1398791061"]QListWidget doesn't have columns afaik (TextMode). Are you talking about IconMode ? What exactly you want to resize ?[/quote]
    Sorry, I was wrong about the QListWidget: it's in reality about QTableWidget.
    so how to do that?



  • Slots: QTableView::resizeColumnToContents(int: column); and
    QTableView::resizeColumnsToContents();
    is what you are searching for. Don't know if it's possible directly from designer (but since they're slots it should be), but in code it is.



  • I found that you can change all columns by going to tableWidget : QTableWidget -> Header -> horizontalHeaderDefaultSectionSize. However, I did not find a QDesigner way of changing a single column width.



  • Hi kaisbs,

    There is way to stretch the column in QTableWidget in Designer also.
    Steps as,

    1. Open the Qt designer.
    2. Select QTableWidget item which you already placed on your form.
    3. See the property box at right hand side.
    4. Scroll down to QTable Widget
    5. Under Header section you will find options to resize it as,
    6. horizontalHeaderDefaultSectionSize increase as you want & try it out
    7. horizontalHeaderStretchLastSection make it true so your empty space after last column will be filled by stretched last column.

    Do your own tryouts on that there are plenty of option to do.

    Thanks
    Prashant Moglaikar


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.