简体   繁体   中英

QTreeview increase view size

I have a QTreeView to which I add QStandardItemModel and QStandardItem. I also set the item font size to be around 600 pixels but sadly the view remains the same size. I thought that sizeHint shout calculate the item proper size and then adjust the view. I tried setting up fixed size via sizeHint but even then the font remained the same size and icon/branch looked off as hell.

The code goes more or less this > :

(Quick mockup)
QTreeView *myView = new QTreeView();
QStandardItemModel *myModel = new QStandardItemModel();
QStandardItem *myItm = new QStandardItem("some test text");
myItm->font().setPointSize(599);
myView->setModel(myModel);
myModel->appendRow(myItm);

I'd like to increase the size of the font/item/icons so that it's more readable.

What you have to do is get the font, change the font size with setPointSize() and then assign the modified font

Complete:

QStandardItem *myItm = new QStandardItem("some test text");
QFont fn = myItm->font();
fn.setPointSize(599);
myItm->setFont(fn);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM