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. Cannot resize a QTableView widget inside an another window
Forum Updated to NodeBB v4.3 + New Features

Cannot resize a QTableView widget inside an another window

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 2.8k 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.
  • Z Offline
    Z Offline
    Zebbik
    wrote on last edited by
    #1

    Hi,

    I've got quite annoying problem. I've put a QTableView in a QWidget that works as an another window. The problem is that QTableView does not resize itself when I resize a window. Also, the window starts with its minimum geometry as if there was none of any layouts at all even though the QTableView is inside. So far, I tried to put QTableView in the one of the layouts: QGridLayout, QHBoxLayout etc. but it does not solve the problem. Am I doing something wrong here? I did not have such a problem before; all layouts with widgets worked great for me.

    Just in case I put the part of the code that is responsible for opening the window.

    @void MyApp::showTabulatedEvents() {
    const int maxRows = dbStoreToday.size();

    upcomingEventsForToday(); // ustaw liste dbStoreToday

    QWidget* tableWindow = new QWidget;
    QVBoxLayout* tableLay = new QVBoxLayout(tableWindow);
    tableWindow->setWindowTitle(trUtf8("Upcoming events for today"));
    QTableView* tableView = new QTableView;
    tableLay->addWidget(tableView);
    tableView->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);

    QStandardItemModel* model = new QStandardItemModel(5,dbStoreToday.size());
    for(int row = 0; row < maxRows; ++row) {
    model->setItem(row,0,new QStandardItem(dbStoreToday[row].imie));
    model->setItem(row,1,new QStandardItem(dbStoreToday[row].nazwisko));
    model->setItem(row,2,new QStandardItem(dbStoreToday[row].nazwa_wyd));
    model->setItem(row,3,new QStandardItem(dbStoreToday[row].data_wyd.toString()));
    model->setItem(row,4,new QStandardItem(tr("%1").arg(dbStoreToday[row].przypomnienie)));
    }
    tableView->setModel(model);
    tableView->show();
    tableWindow->show();
    }@

    This is the window shape I can see when I show the QTableView

    !http://zebik.republika.pl/tableView.jpg(Table View)!

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      You forgot to set the layout on the widget:
      @
      tableWindow->setLayout(tableLay);
      @

      1 Reply Last reply
      0
      • Z Offline
        Z Offline
        Zebbik
        wrote on last edited by
        #3

        I've put
        @setLayout(tableLay);@
        before
        @tableWindow->show();@
        but it still does not work. I am really confused :/

        1 Reply Last reply
        0

        • Login

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