久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

列自動調整為 QTableView 的大小

Columns auto-resize to size of QTableView(列自動調整為 QTableView 的大小)
本文介紹了列自動調整為 QTableView 的大小的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我是 Qt 的新手,我剛剛設法使 QTableView 與我的模型一起工作.它有固定的 3 列.當我打開一個窗口時,它看起來不錯,但是當我調整窗口大小時,QTableView 本身會調整大小,但列的寬度保持不變.有什么內置的方法可以讓它工作嗎?我希望每次調整窗口大小時都調整列的大小以適應 QTableView 的邊緣.

I am new to Qt and I have just managed to make a QTableView work with my model. It has fixed 3 columns. When I open a window, it look ok but when i resize the window, the QTableView itself gets resized but columns' width remains the same. Is there any build-in way to make it work? I want columns to resize to fit the edges of QTableView every the the window gets resized.

推薦答案

有一個標題標志來確保 QTableView 的最后一列在調整大小時填滿其父級.你可以這樣設置:

There is a header flag to ensure that the QTableView's last column fills up its parent if resized. You can set it like so:

table_view->horizontalHeader()->setStretchLastSection(true);

但是,這不會按比例調整其他列的大小.如果你也想這樣做,你可以這樣在你父母的 resizeEvent 中處理它:

However, that does not resize the other columns proportionately. If you want to do that as well, you could handle it inside the resizeEvent of your parent thusly:

void QParent::resizeEvent(QResizeEvent *event) {
    table_view->setColumnWidth(0, this->width()/3);
    table_view->setColumnWidth(1, this->width()/3);
    table_view->setColumnWidth(2, this->width()/3);

    QMainWindow::resizeEvent(event);
}

QParent 類是 QMainWindow 的子類.

QParent class is subclass of QMainWindow.

這篇關于列自動調整為 QTableView 的大小的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How can I read and manipulate CSV file data in C++?(如何在 C++ 中讀取和操作 CSV 文件數據?)
In C++ why can#39;t I write a for() loop like this: for( int i = 1, double i2 = 0; (在 C++ 中,為什么我不能像這樣編寫 for() 循環: for( int i = 1, double i2 = 0;)
How does OpenMP handle nested loops?(OpenMP 如何處理嵌套循環?)
Reusing thread in loop c++(在循環 C++ 中重用線程)
Precise thread sleep needed. Max 1ms error(需要精確的線程睡眠.最大 1ms 誤差)
Is there ever a need for a quot;do {...} while ( )quot; loop?(是否需要“do {...} while ()?環形?)
主站蜘蛛池模板: 欧美aaaaaaaaaa | 精品亚洲一区二区 | 精品一区二区在线观看 | 国产成人精品一区二区三区视频 | 日韩在线播放av | 日日夜夜免费精品 | 成人做爰9片免费看网站 | 亚洲日本一区二区三区四区 | 国产一区二区三区免费观看视频 | 欧美不卡在线 | 丝袜 亚洲 欧美 日韩 综合 | 一区二区三区久久 | 蜜桃av一区二区三区 | 亚洲天天干 | 久久久亚洲 | 国产成人精品免费视频大全最热 | 久久精品视频9 | 青草青草久热精品视频在线观看 | 欧美精品中文字幕久久二区 | pacopacomama在线 | 精品国产免费人成在线观看 | 尤物在线精品视频 | 2021狠狠干| 激情五月婷婷综合 | 国产一区二 | 久久国产精品视频 | 九色网址 | 国产福利视频网站 | 自拍偷拍第一页 | 毛片在线看片 | 9久久精品| 日美女逼逼 | 亚洲天堂网站 | 久色网| 日韩一区中文字幕 | 久久久久久国产精品 | 欧美一区二区在线观看视频 | 日韩不卡在线 | 亚洲va国产日韩欧美精品色婷婷 | 国产精品乱码一区二区三区 | 成人免费视频播放 |