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

Qt Creator QTableview Questions



  • Hello All,
    Have some questions about QTableview.
    I have a QTableview based on a Custom Model/Delegate.
    It displays but has a few issues I'd like to fix.

    I originally wrote this code using (I think) Qt 4.8 when I had Linux Mint 18.0 MATE.
    After upgrade/install to LM 20 MATE, I had to get a new version of Qt Creator.
    I'm using version 6 (I think, it's hard to tell About says 4.13.3 based on 5.15.2 but Kit is 'Desktop Qt 6.0.0 GCC 64bit')
    Anyway, the App I was making before I'm trying to finish now and have it working OK with new version of Qt Creator, with a few issues.

    My QTableview doesn't stay on the main window if I click a menu item.
    The View also doesn't place itself at the very top and left side of the main window. Can't seem to find the method to set it there.
    It also doesn't display the complete view of ALL the columns and rows. I have set both with ..
    view->resizeColumnsToContents();
    view->resizeRowsToContents();
    The Table is 72 x 32.

    Last thing I made this using the Pixalator Example. As I remember, before my Tableview did not have a Window Title and Window Size controls before. The Pixalator Example does not show them either. Did that change or is there a way to set it that way?

    Thanks,
    OtG


  • Lifetime Qt Champion

    @OscarTheGrouch said in Qt Creator QTableview Questions:

    The View also doesn't place itself at the very top and left side of the main window

    Do you use layouts to position it?


  • Lifetime Qt Champion

    Hi @OscarTheGrouch

    I'm using version 6 (I think, it's hard to tell About says 4.13.3 based on 5.15.2 but Kit is 'Desktop Qt 6.0.0 GCC 64bit')

    QtCreator is an IDE, Qt is a library. Your app is created with Creator, but uses just Qt.

    The same way, Creator uses Qt, in your case 5.15.2.

    Your app instead, will use Qt 6.0.

    I hope that cleared it a bit.

    Regard



  • @aha_1980 Yes! Thanks.
    OtG



  • @jsulm said in Qt Creator QTableview Questions:

    @OscarTheGrouch said in Qt Creator QTableview Questions:

    The View also doesn't place itself at the very top and left side of the main window

    Do you use layouts to position it?

    No, that seems to be the issue. My original program did not use the Designer so I did not include some of that code in my current version. Added this ..

    QWidget *centralWidget = new QWidget;
    
    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addWidget(view);
    centralWidget->setLayout(mainLayout);
    setCentralWidget(centralWidget);
    

    And it works now as expected. Thanks!!
    OtG


Log in to reply