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. The bottom border of table header is gone again
Forum Updated to NodeBB v4.3 + New Features

The bottom border of table header is gone again

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 374 Views
  • 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.
  • L Offline
    L Offline
    Lee908
    wrote on last edited by Lee908
    #1

    Re: formatting a QTableView header

    @Christian-Ehrlicher @SGaist @kshegunov

    Hi all, I noted that you have discussed about the related issue in the above topic. And seemly that issue has been fixed. But I reproduced it in some specified situations in windows with Qt 5.14.2 recently.

    It works fine if display a table view in the dialog directly. But the bottom border of table header is gone when the table view is added into a tab widget and then display that tab widget in the dialog. I'm not sure if it's a bug. Hope you could give me a hint if you have any idea about that. Thanks.

    Border is shown:

    QTableView* table = new QTableView;
    table ->horizontalHeader()->setFrameShape(QFrame::HLine); // show border here
    ...
    QVBoxLayout* layout = new QVBoxLayout;
    layout ->addWidget(table);
    
    QDialog* dialog = new QDialog;
    dialog ->setLayout(layout);
    dialog ->show();
    

    Border is missing:

    QTableView* table = new QTableView;
    table ->horizontalHeader()->setFrameShape(QFrame::HLine); // doesn't work
    ...
    QVBoxLayout* layout1 = new QVBoxLayout;
    layout1 ->addWidget(table);
    
    QTabWidget* tab = new QTabWidget;
    tab->setLayout(layout1);
    
    QVBoxLayout* layout2 = new QVBoxLayout;
    layout2 ->addWidget(tab);
    
    QDialog* dialog = new QDialog;
    dialog ->setLayout(layout2 );
    dialog ->show();
    
    JonBJ 1 Reply Last reply
    0
    • L Lee908

      Re: formatting a QTableView header

      @Christian-Ehrlicher @SGaist @kshegunov

      Hi all, I noted that you have discussed about the related issue in the above topic. And seemly that issue has been fixed. But I reproduced it in some specified situations in windows with Qt 5.14.2 recently.

      It works fine if display a table view in the dialog directly. But the bottom border of table header is gone when the table view is added into a tab widget and then display that tab widget in the dialog. I'm not sure if it's a bug. Hope you could give me a hint if you have any idea about that. Thanks.

      Border is shown:

      QTableView* table = new QTableView;
      table ->horizontalHeader()->setFrameShape(QFrame::HLine); // show border here
      ...
      QVBoxLayout* layout = new QVBoxLayout;
      layout ->addWidget(table);
      
      QDialog* dialog = new QDialog;
      dialog ->setLayout(layout);
      dialog ->show();
      

      Border is missing:

      QTableView* table = new QTableView;
      table ->horizontalHeader()->setFrameShape(QFrame::HLine); // doesn't work
      ...
      QVBoxLayout* layout1 = new QVBoxLayout;
      layout1 ->addWidget(table);
      
      QTabWidget* tab = new QTabWidget;
      tab->setLayout(layout1);
      
      QVBoxLayout* layout2 = new QVBoxLayout;
      layout2 ->addWidget(tab);
      
      QDialog* dialog = new QDialog;
      dialog ->setLayout(layout2 );
      dialog ->show();
      
      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @Lee908 said in The bottom border of table header is gone again:

      QTabWidget* tab = new QTabWidget;
      tab->setLayout(layout1);

      I have no idea whether it relates to your issue, but you are not supposed to set a layout on a QTabWidget. It is a container widget, all you are supposed to do is addTab() for the various pages. They can/should be given a layout, but not the QTabWidget.

      L 1 Reply Last reply
      3
      • JonBJ JonB

        @Lee908 said in The bottom border of table header is gone again:

        QTabWidget* tab = new QTabWidget;
        tab->setLayout(layout1);

        I have no idea whether it relates to your issue, but you are not supposed to set a layout on a QTabWidget. It is a container widget, all you are supposed to do is addTab() for the various pages. They can/should be given a layout, but not the QTabWidget.

        L Offline
        L Offline
        Lee908
        wrote on last edited by Lee908
        #3

        @JonB said in The bottom border of table header is gone again:

        It is a container widget, all you are supposed to do is addTab()

        Make a small improvement on my test: create 2 table views with same data and format in a dialog. The left one is added into layout directly, the right one is added via a tab widget as your suggestion. The header bottom border is still missing in the right.

        QTableView* table1 = new QTableView;
        QTableView* table2 = new QTableView;
        table1 ->horizontalHeader()->setFrameShape(QFrame::HLine); 
        table2 ->horizontalHeader()->setFrameShape(QFrame::HLine); 
        ...
        QVBoxLayout* layout = new QVBoxLayout;
        layout ->addWidget(table1);
        
        QTabWidget* tab = new QTabWidget;
        tab->addTab(table2, "Bottom border is missing in header");
        layout ->addWidget(tab);
        
        QDialog* dialog = new QDialog;
        dialog ->setLayout(layout);
        dialog ->show();
        

        微信图片_20221010085254.png

        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