Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Place QWidget inside QTableWidget view



  • I have a QPushButton that I have placed inside a QTableView view. However when the number of items in the table reaches the maximum, the button gets pushed out of the view and it's not possible to press it. How can I anchor it to the bottom of the view?


  • Lifetime Qt Champion

    Hi,

    The most simple would likely be to position it manually rather than in a cell and update its position when the widget is resized.



  • @imaqt-0
    It does not sound like it belongs there, place it after the view instead of in the view and then you wouldn't have a problem?



  • Hello,
    I think I didn't do a good job explaining the situation.
    0_1554712729814_file.gif
    I have the insert row button, which is positioned after the last table row. The problem is that the view doesn't allow me to scroll to it. How can i fix this?


  • Lifetime Qt Champion

    Hi
    Did you place it on an item ?
    with setCellWidget ?



  • @imaqt-0
    If you maintain having the button as a cell widget you're in a sticky situation.

    If you have the button placed after the QTableWidget (i.e. it is not a cell widget, it is a sibling of the whole table), any scroller on the table is not going to get you to the button. Make it so the table takes up all space except for allowing the button below it, which is always visible.

    This really should not be very hard. Please indicate clearly whether your button is a cell widget or a widget placed after the QTableWidget.



  • Hello,
    I created the button with:

    button = new QPushButton(table->viewport());
    

    and I update its position on the table to be after the last row each time a new row is inserted.


Log in to reply