Qcombobox Setting the width of the drop-down box

Source: Internet
Author: User

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
    1. Setstylesheet ("Qcombobox {min-height:40px; min-width:60px; }"  
    2. "Qcombobox Qabstractitemview::item {min-height:40px; min-width:60px;  }");
    3. Qcombobox *combo = new Qcombobox (this);
    4. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.