Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Center table in widget/window
Forum Updated to NodeBB v4.3 + New Features

Center table in widget/window

Scheduled Pinned Locked Moved Unsolved General and Desktop
qtablewidgetcenter
2 Posts 2 Posters 1.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    Gianluca86
    wrote on 4 Aug 2016, 07:27 last edited by Gianluca86 8 Apr 2016, 07:28
    #1

    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

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 4 Aug 2016, 20:18 last edited by
      #2

      Hi,

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

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0

      1/2

      4 Aug 2016, 07:27

      • Login

      • Login or register to search.
      1 out of 2
      • First post
        1/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved