Home > Mobile >  Consult about QComboBox problems in use
Consult about QComboBox problems in use

Time:04-09

, ladies and gentlemen, here is my use QComboBox, code is as follows:

M_comboPro=new QComboBox (this);
M_comboPro - & gt; SetStyleSheet (" QComboBox {border - image: url (:/res/PWD/comboBoxBkg PNG); The font-family: "SimHei"; font-size:13px; Color: # 003 da6; Border: 1 px solid gray; }
""QComboBox QAbstractItemView {background: rgba (255255255, 1); Border: 1 px solid rgba (228228228, 1); Border - the radius: 0 px 0 px 5 px 5 px; font-size:13px; Outline: 0 px; }
""QComboBox QAbstractItemView: : item {min - height: 13 px; }
""QComboBox: : the drop - down {border - left - width: 1 px; Border - left - color: lightgray; Border - left - style: solid; Border - top - right - the radius: 3 px; Border - bottom - right - the radius: 3 px; Subcontrol - origin: padding; Subcontrol - position: top right; Width: 18 px; }
""QComboBox: : down - arrow {image: url (:/res/PWD/arrowDown0 PNG)}"
"QComboBox: : down - arrow: hover {image: url (/res/PWD/arrowDown0. PNG)}"
"QComboBox: : down - arrow: pressed {image: url (:/res/PWD/arrowDown0 PNG)}");
M_comboPro - & gt; AddItem (" when is your birthday?" );
M_comboPro - & gt; AddItem (" how much is your student id?" );
Delegate QStyledItemDelegate *=new QStyledItemDelegate (this);
M_comboPro - & gt; SetItemDelegate (delegate);
QImage comboBoxImg (" :/res/PWD/comboBoxBkg PNG ");
M_comboPro - & gt; The resize (comboBoxImg. The size ());
M_comboPro - & gt; Move (this - & gt; Width () * 8/100 + m_labelFst - & gt; Width (), and this - & gt; Height () * 17/100);
The connect (m_comboPro, SIGNAL (currentIndexChanged (int)), and this, SLOT (slotClickedComboBox (int)));
What method can let QComboBox text on the left, and then the far left, isn't it? . Also, is the res/PWD/arrowDown0 PNG down arrow, can move to the right a certain position (because the down arrow is right, not fully display)? In the end, if not the position of the moving window QDialog, click the down arrow, it is not a dislocation phenomenon, but once the moving window, click the down arrow, dislocation will appear options? Is there a way to solve these problems? Please give a bosses to give directions, I here really appreciate!

CodePudding user response:

No picture can't accurate grasp your requirements,
What method can let QComboBox text on the left, and then the far left, isn't it?
The default styles this won't be on the left, there will be a certain margin,
Fine-tuning padding - left: 2 px; Can adjust the distance to the border, numerical according to need to modify,

Down arrow, can move to the right position (because the down arrow is right, not fully display) : be left -- --
The down - arrow is drawn on the drop - down,
Down - arrow image with geometric scaling down - arrow's size.
The drop - down to set the width to 18.
Want a down - arrow all displayed, you need to specify the down - the size of the arrow, no more than 18,
QComboBox: : down - arrow
{
Widtd: 18 px;
Height: 18 px;
Image: url (:/res/PWD/arrowDown0 PNG)
}

The last question, had better have figure

CodePudding user response:

reference 1/f, Laura Tony reply:
no figure can't accurate grasp your requirements,
What method can let QComboBox text on the left, and then the far left, isn't it?
The default styles this won't be on the left, there will be a certain margin,
Fine-tuning padding - left: 2 px; Can adjust the distance to the border, numerical according to need to modify,

Down arrow, can move to the right position (because the down arrow is right, not fully display) : be left -- --
The down - arrow is drawn on the drop - down,
Down - arrow image with geometric scaling down - arrow's size.
The drop - down to set the width to 18.
Want a down - arrow all displayed, you need to specify the down - the size of the arrow, no more than 18,
QComboBox: : down - arrow
Hi, bosses, screenshot is as follows:

{
Widtd: 18 px;
Height: 18 px;
Image: url (:/res/PWD/arrowDown0 PNG)
}

The last question, had better have figure


reference 1/f, Laura Tony reply:
no figure can't accurate grasp your requirements,
What method can let QComboBox text on the left, and then the far left, isn't it?
The default styles this won't be on the left, there will be a certain margin,
Fine-tuning padding - left: 2 px; Can adjust the distance to the border, numerical according to need to modify,

Down arrow, can move to the right position (because the down arrow is right, not fully display) : be left -- --
The down - arrow is drawn on the drop - down,
Down - arrow image with geometric scaling down - arrow's size.
The drop - down to set the width to 18.
Want a down - arrow all displayed, you need to specify the down - the size of the arrow, no more than 18,
QComboBox: : down - arrow
{
Widtd: 18 px;
Height: 18 px;
Image: url (:/res/PWD/arrowDown0 PNG)
}

The last question, had better have figure


Bosses, screenshots are as follows:


As shown in the screenshot, the problem 1. The text in the QComboBox can move a little right, too, on the left
Q.2 down arrow can be moving to the left a little bit, because the down arrow pictures was rectangular, the results because I don't know how to set its properties, thus becomes a looks like a triangle, too on the right side,
Q.3 dislocation has been solved,
Finally to achieve the effect similar to the screenshot below:


CodePudding user response:

The following is about The effect you want, padding values need to be properly, a little specific meaning not explain one by one, advice to see qt help in The Style Sheet Syntax, have a more detailed introduction inside also has a lot of examples,
H - ComboBox height
QComboBox {
Max - height: Hpx;
Min - height: Hpx;
Border - the radius: H/2 p;
Padding - left: H/2 p;
}

QComboBox: : the drop - down {
border:none;
Padding - right: H/2 p;
Width: Hpx;
}
QComboBox: : down - arrow/* the size of the set set up combining the drop-down arrow images of the actual size, but not beyond the size of the drop - down */
{
Width: Hpx;
Height: Hpx;
}

CodePudding user response:

reference Laura Tony reply: 3/f
The following is about The effect you want, padding values need to be appropriate, a little specific meaning not explain one by one, and advice to see qt help in The Style Sheet Syntax, have a more detailed introduction inside also has a lot of examples,
H - ComboBox height
QComboBox {
Max - height: Hpx;
Min - height: Hpx;
Border - the radius: H/2 p;
Padding - left: H/2 p;
}

QComboBox: : the drop - down {
border:none;
Padding - right: H/2 p;
Width: Hpx;
}
QComboBox: : down - arrow/* the size of the set set up combining the drop-down arrow images of the actual size, but not beyond the size of the drop - down */
{
Width: Hpx;
Height: Hpx;
}

Thank you for your bosses to give directions, and then ask a question, and more is
QImage comboBoxImg (" :/res/PWD/comboBoxBkg PNG ");
ComboBoxImg. Height () is the unit of px? nullnullnullnullnullnullnull
  •  Tags:  
  • Qt
  • Related