These days to write a project, which uses the Qcombobox component, where the drop-down box contains 129 children, so when clicked, a drop-down box will be full of computer screen, it is not good-looking and in use will cause great distress. In fact, I just want to set the maximum height of a drop-down box, and the rest of the children that are not shown are replaced with a scroll bar.
Search on the internet for a long time, many are the same, can not solve the problem, so today, write down this blog, one, left to their own archives, and to the later students, hope not to go my old road.
The drop-down box height is mainly divided into two kinds.
The height of a drop-down frame:
[CPP]View PlainCopy
- Setstylesheet ("Qcombobox {min-height:40px; min-width:60px; }"
- "Qcombobox Qabstractitemview::item {min-height:40px; min-width:60px; }");
- Qcombobox *combo = new Qcombobox (this);
- Combo->setview (new Qlistview ());
The height of drop-down list of drop-down box:
We usually use this statement
Ui->m_qcombxtype->setmaxvisibleitems (10);
Sets the maximum number of subkeys to drop down, which is the height of the drop-down box. But in the use of the time found no response, can not be used. In front of this statement, add a sentence
Ui->m_qcombxtype->seteditable (TRUE);
Set Qcombobox as an editable property. You can do it.
Where M_qcombxtype is the name of the drop-down box.
http://blog.csdn.net/devil_box/article/details/46514007
Qcombobox Setting the width of the drop-down box