PDA

View Full Version : How to make Custom Combobox ?



qt_man
15th March 2010, 07:28
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

zgulser
15th March 2010, 07:33
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*/}
}

qt_man
15th March 2010, 10:45
Thanx zgulser for prompt reply.

I will try to implement it, but what should I use for inserting items in combobox.

mani

prof.ebral
15th March 2010, 11:07
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.

kinjalp
15th February 2012, 05:01
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.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...

7404