Center table in widget/window



  • Hi everyone,
    I want to be able to put at the center of a widget (or window) a table, more precisely a QTableWidget.
    I tried using the following command.

    QTableWidget Table = new QTableWidget(20,2,this);
    Table->setEditTriggers(QAbstractItemView::NoEditTriggers);
    Table->setSelectionMode(QAbstractItemView::SingleSelection);
    Table->setFrameStyle(QFrame::NoFrame);   
    Table->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
    Table->verticalHeader()->setVisible(FALSE);
    
    verticalLayout->addWidget(Table);
    verticalLayout->setAlignment(Table,Qt::AlignHCenter);
    

    The table actually is positioned in the center, but it is cut in the right side, the scrollbar appears, but I want to see the entire table without scroolbar.
    Thank you


  • Lifetime Qt Champion

    Hi,

    If you don't want any scrollbars then you have to ensure that the widget is big enough to show everything.


Log in to reply