QTableView and setSortingEnabled



  • Hello. I have got a question about the influence of setSortingEnabled on the size of the window. My code is here
    @ui->TransportView->horizontalHeader()->setSectionResizeMode(0,QHeaderView::Stretch);
    ui->TransportView->horizontalHeader()->setSectionResizeMode(1,QHeaderView::Stretch);
    ui->TransportView->horizontalHeader()->setSectionResizeMode(2,QHeaderView::Stretch);
    ui->TransportView->horizontalHeader()->setSectionResizeMode(30,QHeaderView::Stretch);
    ui->TransportView->horizontalHeader()->setSectionResizeMode(31,QHeaderView::ResizeToContents);
    ui->TransportView->horizontalHeader()->setSectionResizeMode(32,QHeaderView::ResizeToContents);
    ui->TransportView->horizontalHeader()->setSectionResizeMode(33,QHeaderView::ResizeToContents);
    ui->TransportView->horizontalHeader()->setSectionResizeMode(34,QHeaderView::ResizeToContents);
    ui->TransportView->horizontalHeader()->setSectionResizeMode(35,QHeaderView::ResizeToContents);
    ui->TransportView->horizontalHeader()->setSectionResizeMode(36,QHeaderView::ResizeToContents);
    ui->TransportView->horizontalHeader()->setSectionResizeMode(37,QHeaderView::ResizeToContents);
    ui->TransportView->horizontalHeader()->setSectionResizeMode(38,QHeaderView::ResizeToContents);
    ui->TransportView->horizontalHeader()->setSectionResizeMode(39,QHeaderView::ResizeToContents);
    ui->TransportView->horizontalHeader()->setSectionResizeMode(40,QHeaderView::ResizeToContents);
    ui->TransportView->horizontalHeader()->setSectionResizeMode(41,QHeaderView::ResizeToContents);
    for (int i=3;i<30;i++)
    {
    ui->TransportView->setColumnHidden(i,true);
    }
    for (int i=42;i<80;i++)
    {
    ui->TransportView->setColumnHidden(i,true);
    }
    ui->TransportView->setSortingEnabled(true);

    ui->TransportView->setSelectionBehavior(QAbstractItemView::SelectRows);@
    So when I set SortingEnabled to true, setSectionResizeMode seems not to work(the width of the columns becomes much smaller than the width of their contents).Is it possible somehow or am I doing smth wrong? And moreover the width of the dialog becomes much bigger when using setSortingEnabled(true).And I can't let it happen, cause I have to stick to the screen resolution.Thanx a lot for any help!=)



  • Hi,
    Maybe check out the QSortFilterProxyModel instead?
    Greetz



  • Ok, I will try.But this behaviour seemed very strange to me.So I wanted to know if there is any reason for that. Thanx=)))


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.