PDA

View Full Version : Custom Combobox



zgulser
16th April 2009, 10:41
Hi,

I want to make invisible the combobox down-arrow. I tried to do that from the setStyleSheet by using down-arrow sub-control but I couldn't do it.

::down-arrow{image: url(none.jpg);}

I now trying paintEvent with drawControl thing. I might go wrong but I couldn't find another way upto now.

Thanks in advance.

wysota
16th April 2009, 11:34
How do you intend to open the combobox without the arrow?

zgulser
16th April 2009, 12:07
I want only the down-arrow to disappear. The little rect just under the down-arrow which appears in the MotifStyle must stay where it is. I guess they are together the down-arrow from your message. Even if it is so, I tried to change the image of the down-arrow (i.e. combobox.png instead none.png) but nothing changes.

wysota
17th April 2009, 10:21
What is the complete stylesheet you tried and what did you apply it on?

aekilic
17th April 2009, 13:01
Why dont you just use QLineEdit and QCompleter::PopupCompletion if you dont need arraws. I will just behave like combo?

zgulser
20th April 2009, 10:23
all is the following :)

::down-arrow{image: url(none.jpg);

and I want to apply it on QCombobox as usual.

zgulser
20th April 2009, 15:18
Any ideas?

zgulser
22nd April 2009, 09:03
Hi,

I wonder why the following doesn't work...I tried it from the designer just like that but it did not work.
Maybe I'm missing something or maybe it's qt's bug. Please help about this situation.

::down-arrow {
subcontrol-origin: content;
subcontrol-position: center;
position: relative;
left: 1px; /* 1 pixel dropdown border */
}

zgulser
22nd April 2009, 09:31
Hi again,

I solve my initial problem by doing

::drop-down::down-arrow instead of ::down-arrow only, but this time I lost the frame around my combobox...!:confused:

zgulser
27th April 2009, 07:55
Any ideas?

wysota
27th April 2009, 20:07
Which frame? Which widget style are you using?

zgulser
28th April 2009, 07:33
Hi,

I said the wrong word I guess. I meant the border around my combobox.

I'm using motifstyle and once I apply this ;

::drop-down::down-arrow{image: url(mycustomicon.PNG)}

the combobox's down arrow takes my new icon but the combobox itself appears like borderless.

wysota
28th April 2009, 08:07
If you use stylesheets, the current style gets replaced with a dynamically created one which acts as a proxy between the base style and the widget. Then it might happen you lose more of the default style then what you'd like. In this situation you have to use stylesheets to style the widget more - in your case bring back the frame (using the "border" css property).

zgulser
28th April 2009, 10:08
Hi,

I already did what you said about using "border" property.

I have tried both of the following ways to achieve my goal;

1- ::drop-down{border-style: outset; border-width:1px}

2- ::drop-down::down-arrow{image: url(mycustomicon.PNG); border-style: outset; border-width: 1px}

But both ways only cover around my down-arrow icon not the combobox:confused:

zgulser
28th April 2009, 10:29
Problem solved!

first way works with some minor changes.

But now, I couldn't access the combobox items to give them style. What I want to do is when I click the drop-down, the list of items appeared changes it's background color. I looked at the docs but couldn't find a solution.

zgulser
29th April 2009, 10:02
Any ideas?

wysota
29th April 2009, 11:14
Any ideas?

Is there a question here somewhere?

zgulser
4th May 2009, 07:33
Yes there is,

I want to access the background of the combobox when the drop-down button is clicked. :)

wysota
4th May 2009, 08:37
The component is a listview (by default) so you have to style it as it was a QListView.

QListView { background: red; }

zgulser
5th May 2009, 10:19
Thanks mate!

Utkarsh Nayak
4th April 2012, 11:13
Hi all,
I am new to Qt and i am facing problem regarding drop down list of combo box. By default there is a drop down list in which i can add the items using the form.
Instead of that default drop down list image i want to have my own image, which popups when i click the combo box.

Thanks in advance.