Putting text to border top of qlineedit - qt

I'm working in Qt 5.12. I should create a qlineedit shape in a form, like below:
But I can not write style sheet for it.

I think I managed:
I put QLineEdit into QGroupBox, and set a layout for QGroupBox. And set both horizontal and vertical policy to preferred for QLineEdit. My Style Sheet:
QLineEdit{
border: none;
font: 10pt "Segoe UI";
}
QGroupBox {
border: 1px solid #C4C4C4;;
border-radius: 20px;
margin-top: 10px
}
QGroupBox::title {
subcontrol-origin: margin;
subcontrol-position: top left; /* position at the top left */
color: #C4C4C4;
left: 15px;
}

Related

Adjust title position in a QGroupBox (using style sheets)

I am trying to style a QGroupBox to match certain design requirements:
Note - the group title on top should be on the left but past the box curvature.
With the following style sheet, I get the images below (second image if I remove the word "left"):
QGroupBox {
font: bold;
border: 1px solid silver;
border-radius: 6px;
margin-top: 6px;
}
QGroupBox::title {
subcontrol-origin: margin;
subcontrol-position: top left; // for second image: top;
padding: 0 2px 0 2px;
}
So, it seems what I want is subcontrol-position: top left; but with an added offset. I could not find that anywhere.
Adding padding erases the line, so it is not what I want.
There is one option I found just now - a different option for subcontrol-origin::
QGroupBox::title {
subcontrol-origin: padding;
subcontrol-position: top left;
padding: -16 12px 0 12px;
}
It looks almost right - but the border now cuts through the title.
How can I move the title of the group box, so that it is still on left but past the box curvature, and the curvature to stay visible, such as in the design ?
Applying the following style:
QGroupBox {
font: bold;
border: 1px solid silver;
border-radius: 6px;
margin-top: 6px;
}
QGroupBox::title {
subcontrol-origin: margin;
left: 7px;
padding: 0px 5px 0px 5px;
}
I get something like this:

How to create a new menu with style and button with QMenu

I need to create a menu example like this when we click to the plus icon
I just created the text.
QMenu *menu = new QMenu(this);
menuicd->addAction("Choose the job from:");
menuicd->addAction("Our job portal");
menuicd->addAction("Our database");
menuicd->addAction("University website");
ui.plusbutton->setMenu(menu);
How can I make the white text with blue background for the options? And how can i add the cancel button in this menu?
If you want to create a custom context menu you can use a style sheet
like that:
QMenu
{
border: 1px solid #76797C;
color: #eff0f1;
margin: 2px;
}
QMenu::icon
{
margin: 5px;
}
QMenu::item
{
padding: 5px 30px 5px 30px;
margin-left: 5px;
border: 1px solid transparent; /* reserve space for selection border */
}
But this image is like a QDialog

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;
}

font-awsome - producing a large icon with text centered below it using :before

Can this be done with icon font and :before?
Aim: a large icon centered in a div with a text label centered below it.
The old way I would do this would be a background image and padding-top to render the image above the div content.
Would prefer to use an icon font. Displaying an icon to the left of the text is easy enough using :before but is it possible to display it above instead?
Thanks.
EDIT: I have no code other than bog standard icon font usage:
.mydiv:before {
content: "\f11c "; /* this is the Unicode for the icon */
font-family: FontAwesome;
margin-right: .2em;
}
this places an icon befor the text. Don't even know if possible to posisiton it above instead.
Could it be something like this?
.mydiv {
font-family: sans-serif;
width: 120px;
padding: 10px 0;
text-align: center;
border: 1px solid #000;
border-radius: 3px;
background: #333;
color: #fff;
}
.mydiv:before {
content: "\f11c ";
font-family: FontAwesome;
display: block;
margin-right: .2em;
text-align: center;
}
http://jsfiddle.net/4W8dg/

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