How to make Custom Combobox ?
Hi,
I am trying to create a combo box using QLineEdit, QGraphicsWidget for pop down list and arrow image for drop-down/up arrow and some how got success in simulating combobox partially. But I am not able to insert text in the list view. It is also required that, if list is empty,
combo box should not show, drop down arrow. Please suggest How can I do that.
Regards,
mani
Re: How to make Custom Combobox ?
Quote:
It is also required that, if list is empty,
combo box should not show, drop down arrow
To do this, you need to play with style sheets. You have to do something like;
if list is empty
QComboBox::drop-down::down-arrow {
image: url{/*nothing or empty image file*/}
}
else
QComboBox::drop-down::down-arrow {
image: url{/*default image*/}
}
Re: How to make Custom Combobox ?
Thanx zgulser for prompt reply.
I will try to implement it, but what should I use for inserting items in combobox.
mani
Re: How to make Custom Combobox ?
Just curious .. do you really need to go that way around or is this something that you want to accomplish?
With a QComboBox you can use setEditable(True) and the ComboBox will be editable. If you want the drop down arrow not visible when their are no items, then you can turn the QComboBox into a QLineEdit until more items are available.
That's my two cents.
2 Attachment(s)
Re: How to make Custom Combobox ?
Hi zgulser,
this is working fine..
but this code has problem that another style sheet colour change property is not use in runtime so you have any option for that both the property i will use in the combo box
kinjal.
Added after 28 minutes:
Hi zgulser,
I want to also ask that how to remove side bar that shown after hide down arrow in the combo box. as shown in figure how off centre the combo box item.Attachment 7403
Added after 5 minutes:
Hi zgulser ,
I want to also ask how to remove side bar and make item of combo box in centre ... I have problem of off centre the item in combo box as shown in figure...
please help me out in this...
Attachment 7404