How to style Scrollview for QCombobox? - qt

I need to apply style sheet for the QCombobox. Can anyone please give
me an example? I thought using the QScrollView will affect the
QCombobox but it didn't. And how to limit the number of items shown in
a combo box?

You should start from official documentation for QCombobox stylesheets. Basically it is like:
QComboBox {
border: 1px solid gray;
border-radius: 3px;
padding: 1px 18px 1px 3px;
min-width: 6em;
}
QComboBox:editable {
background: white;
}
You can limit number of visible items in QComboBox by using maxVisibleItems property.

Related

webkit - css styling not working

The selection button as shown in the image below is not showing in my css set up for the select option of the website.
http://www.thefixedgearshop.com/nl/frames/aventon-frames/aventon-cordoba-frameset-wit
Select option without the button:
Select option with button:
Button that is missing:
Here is the CSS code for the option:
product-options dd select {
width: 100%;
border: 2px solid #aab2bd;
background-color: #f4f4f4;
width: 100%;
border: 2px solid #aab2bd;
color: #666;
font-size: 13px;
padding: 9px;
border-radius: 3px;
border: 1px solid #999;
-webkit-appearance: none;
cursor: pointer;
A way I've seen custom dropdowns done before is by using the little drop caret as a background-image with a background-position value of whatever puts it in the right place for your design.
Have a look at the pages linked below.
Background-image attribute W3Schools
Background-position attribute W3Schools

how to set stylesheet for groupbox title in QT

I have a widget with groupbox. I set the border for the groupbox using stylesheet that also works fine, but the border is not fit with the groupbox title. I searched in google, they suggest to change the groupbox title like:
QGroupBox::title {
background-color: transparent;
subcontrol-position: top left; /* position at the top left*/
padding: 2px 13px;
}
In my code i used the stylesheet like:
ui->groupBox->setStyleSheet("border: 1px solid gray;"
"border-radius: 9px;"
"margin-top: 0.5em;");
so how to apply setstylesheet property for the groupbox title, guide me.
Apply such stylesheet to parent of groupBox:
this->setStyleSheet("QGroupBox::title {"
"background-color: transparent;"
"padding-top: -24px;"
"padding-left: 8px;} ");
In my case it was MainWindow.
Also you can edit stylesheet from QtDesigner by calling "Edit styleSheet..." menu on required widget. I prefer to edit my MainWindow stylesheet to keep all code in one place.
In QtDesigner CSS will looks like this (this is stylesheet of QGroupBox parent):
QGroupBox {
border: 1px solid gray;
border-radius: 9px;
margin-top: 0.5em;
}
QGroupBox::title {
background-color: transparent;
padding-top: -24px;
padding-left: 8px;
}

Styling an exterior border on form inputs

I'm hoping somebody can help me answer this, as hours of Googling is not proving fruitful. I currently have this code styling my form labels:
label {
display:inline-block;
height: 15px;
width: 350px;
float: left;
padding: 5px;
border-top: 1px solid black;
color: black;
font-size: 12px;
}
I would like to style the same border-top property to my input, textarea and select tags. However, styling border-top on these elements styles the obvious, the border around the element itself. I would like to know if its possible to display the border outside, or if I need to use other properties to achieve my desired result.
If you mean that the borders look inset than you need simply
input {
border: 0;
border-top: 1px solid #333;
}
And if you literally means OUTSIDE so you can use something like shadow to spoof
Demo
CSS
input {
box-shadow: 0px -1px 1px -1px #333;
border: none;
margin: 50px;
}
If you want to have a border outside the elements, you will need a block element around each of the input, textarea or select (probably div if no element is semantically relevant). These blocks will receive the border and you can adjust the distance between the form elements and the border with padding-top on the div
This also has the advantage that border on div is way better supported than border on form elements.

The DropDown button of ComboBox appear far from the Input Box

I am using AjaxControlToolkit's ComboBox control. The DropDown arrow appears quite far from the actual position where it should be. See this image:
How to fix this to make it appear like an ideal DropDownList?
If the image doesn't appear, click this link: http://postimage.org/image/99yqullkb/
**** Edited (CSS Code) ****
.WindowsStyle .ajax__combobox_inputcontainer .ajax__combobox_textboxcontainer input
{
margin: 0;
padding: 0px 0px 1px 0px;
border: solid 1px #7F9DB9;
border-right: 0px none;
font-size: 13px;
height: 18px;
width:200px;
}
.WindowsStyle .ajax__combobox_inputcontainer .ajax__combobox_buttoncontainer button
{
padding: 0px 0px 10px 0px;
height: 21px;
width: 21px;
}
.WindowsStyle .ajax__combobox_itemlist
{
border-color: #7F9DB9;
}
Looks like a CSS styles side-effect. Check calculated styles for arrow button and it's container with some tool like FireBug or Developer Tools.
IAE try to apply the style rule below, maybe it fix the issue:
table.ajax__combobox_inputcontainer td
{
padding: 0 !important;
text-align: left !important;
}
table.ajax__combobox_inputcontainer td.ajax__combobox_buttoncontainer button
{
margin-left: 0 !important;
}
If you are using width property like width="20%" then this problem occurs. Avoid "%" in width property and try with exact width in pixels like width="200px".

Combobox Telerik - change color

I'm using the combobox control:
http://demos.telerik.com/aspnet-mvc/razor/ComboBox?theme=vista
And I want it to be not white, like it is now. Which css property can do this? Is it possible?
I want it to look like this:
You should be able to achieve that with a custom background color on the select element and some rounded corners on its container. Try placing the combobox in a containing DIV and give it these CSS styles:
.rounded {
border-radius: 10px;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
padding: 5px;
background: #333;
}
.rounded select {
width: 100%;
background: #333;
color: #fff;
border: 0;
outline: 0;
}
http://jsfiddle.net/mpHgR/1/
It might be a little off, but it's close to what you want.

Resources