本文整理汇总了C++中QLabel::setAutoFillBackground方法的典型用法代码示例。如果您正苦于以下问题:C++ QLabel::setAutoFillBackground方法的具体用法?C++ QLabel::setAutoFillBackground怎么用?C++ QLabel::setAutoFillBackground使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QLabel
的用法示例。
在下文中一共展示了QLabel::setAutoFillBackground方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QWidget
// CppTypeHierarchyWidget
CppTypeHierarchyWidget::CppTypeHierarchyWidget(Core::IEditor *editor) :
QWidget(0),
m_cppEditor(0),
m_treeView(0),
m_model(0),
m_delegate(0)
{
QVBoxLayout *layout = new QVBoxLayout;
layout->setMargin(0);
layout->setSpacing(0);
if (CPPEditor *cppEditor = qobject_cast<CPPEditor *>(editor)) {
m_cppEditor = static_cast<CPPEditorWidget *>(cppEditor->widget());
m_model = new QStandardItemModel;
m_treeView = new Utils::NavigationTreeView;
m_delegate = new AnnotatedItemDelegate;
m_delegate->setDelimiter(QLatin1String(" "));
m_delegate->setAnnotationRole(AnnotationRole);
m_treeView->setModel(m_model);
m_treeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
m_treeView->setItemDelegate(m_delegate);
layout->addWidget(m_treeView);
connect(m_treeView, SIGNAL(clicked(QModelIndex)), this, SLOT(onItemClicked(QModelIndex)));
connect(CppPlugin::instance(), SIGNAL(typeHierarchyRequested()), this, SLOT(perform()));
} else {
QLabel *label = new QLabel(tr("No type hierarchy available"), this);
label->setAlignment(Qt::AlignCenter);
label->setAutoFillBackground(true);
label->setBackgroundRole(QPalette::Base);
layout->addWidget(label);
}
setLayout(layout);
}
示例2: paint
void FilterItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
QAbstractItemView *view = qobject_cast<QAbstractItemView*>(parent());
QLabel *label;
if (view->indexWidget(index) == 0)
{
label = new QLabel();
label->installEventFilter(filter);
label->setAutoFillBackground(true);
label->setFocusPolicy(Qt::TabFocus);
label->setText(index.data().toString());
view->setIndexWidget(index, label);
}
label = (QLabel*)view->indexWidget(index);
if (option.state & QStyle::State_Selected)
if (option.state & QStyle::State_HasFocus)
label->setBackgroundRole(QPalette::Highlight);
else
label->setBackgroundRole(QPalette::Window);
else
label->setBackgroundRole(QPalette::Base);
}
示例3: f
FlashableWidget::FlashableWidget(int width, int height, QWidget *parent):
QWidget(parent) ,vLabels_(), width_(width), height_(height),
vActiveLabels_(), inactiveLabelPalette(), activeLabelPalette(),
backgroundPalette(), currentHalve(0), selectedHalveWidth(0),
selectedHalveHeight(0), firstHalveWidth(0), firstHalveHeight(0),
secondHalveWidth(0), secondHalveHeight(0)
{
grid = new QGridLayout;
QFont f("Helvetica", 20);
for(int row = 0; row < height_; ++row)
{
for(int column = 0; column < width_; ++column)
{
QLabel *label = new QLabel();
label->setFont(f);
label->setScaledContents(true);
label->setFrameShape(QFrame::Box);
label->setLineWidth(3);
label->setAlignment(Qt::AlignCenter);
label->setPalette(inactiveLabelPalette);
label->setAutoFillBackground(true);
grid->addWidget(label, row, column);
vLabels_.push_back(label);
}
}
setLayout(grid);
oneByOneIndex_ = 0;
}
示例4: AddColor
void OBSPropertiesView::AddColor(obs_property_t *prop, QFormLayout *layout,
QLabel *&label)
{
QPushButton *button = new QPushButton;
QLabel *colorLabel = new QLabel;
const char *name = obs_property_name(prop);
long long val = obs_data_get_int(settings, name);
QColor color = color_from_int(val);
button->setText(QTStr("Basic.PropertiesWindow.SelectColor"));
colorLabel->setFrameStyle(QFrame::Sunken | QFrame::Panel);
colorLabel->setText(color.name(QColor::HexArgb));
colorLabel->setPalette(QPalette(color));
colorLabel->setAutoFillBackground(true);
colorLabel->setAlignment(Qt::AlignCenter);
QHBoxLayout *subLayout = new QHBoxLayout;
subLayout->setContentsMargins(0, 0, 0, 0);
subLayout->addWidget(colorLabel);
subLayout->addWidget(button);
WidgetInfo *info = new WidgetInfo(this, prop, colorLabel);
connect(button, SIGNAL(clicked()), info, SLOT(ControlChanged()));
children.emplace_back(info);
label = new QLabel(QT_UTF8(obs_property_description(prop)));
layout->addRow(label, subLayout);
}
示例5: GcWindow
DialWindow::DialWindow(MainWindow *mainWindow) :
GcWindow(mainWindow), mainWindow(mainWindow), average(1), isNewLap(false)
{
rolling.resize(150); // enough for 30 seconds at 5hz
setContentsMargins(0,0,0,0);
setInstanceName("Dial");
QWidget *c = new QWidget;
QVBoxLayout *cl = new QVBoxLayout(c);
setControls(c);
// setup the controls
QFormLayout *controlsLayout = new QFormLayout();
controlsLayout->setSpacing(0);
controlsLayout->setContentsMargins(5,5,5,5);
cl->addLayout(controlsLayout);
// data series selection
QLabel *seriesLabel = new QLabel(tr("Data Series"), this);
seriesLabel->setAutoFillBackground(true);
seriesSelector = new QComboBox(this);
foreach (RealtimeData::DataSeries x, RealtimeData::listDataSeries()) {
seriesSelector->addItem(RealtimeData::seriesName(x), static_cast<int>(x));
}
示例6: updateLegend
void TimeAnalysisWidget::updateLegend()
{
std::vector<std::string> &labels = _selectedScalar->labels();
// removinb previous legend
QFormLayout *layout = (QFormLayout *)_ui->legendGroupBox->layout();
QLayoutItem *child;
while (layout->count()!=0 && (child = layout->takeAt(0)) != 0) {
child->widget()->deleteLater();
delete child;
}
for (unsigned i=0; i<labels.size(); ++i) {
QLabel *colorLabel = new QLabel;
colorLabel->setAutoFillBackground(true);
colorLabel->setMinimumSize(70, 15);
QPalette palette = colorLabel->palette();
float denom = _selectedScalar->max() - _selectedScalar->min();
float normalizedValue = ( i - _selectedScalar->min() ) / ( denom == 0 ? 1.f : denom );
palette.setColor(colorLabel->backgroundRole(), _ui->projectionWidget->colorScale()->getColor(normalizedValue));
colorLabel->setPalette(palette);
layout->addRow(new QLabel(labels[i].c_str()), colorLabel);
}
repaint();
}
示例7: initializeWidget
void MorePage::initializeWidget()
{
//导航栏
QString strTitle = tr("更多...");
navigationBar = new NavigationBar(this);
navigationBar->setTitleText(strTitle);
QHBoxLayout* pHLTop = new QHBoxLayout();
pHLTop->addWidget(navigationBar);
pHLTop->setSpacing(0);
pHLTop->setMargin(0);
this->setTopbarLayout(pHLTop);
//个人信息
QLabel* themeWidget = new QLabel;
QPixmap pixmap = QPixmap(ImagePath::MOREPAGE_THEME);
pixmap.setDevicePixelRatio(2);
themeWidget->setAutoFillBackground(true);
themeWidget->setFixedHeight(this->screenHeight()*0.25);
themeWidget->setFixedWidth(this->screenWidth());
themeWidget->setPixmap(pixmap);
themeWidget->setScaledContents(true);
btnPersonalInfo = new QToolButton;
btnPersonalInfo->setFixedWidth(this->screenWidth());
btnPersonalInfo->setFixedHeight(this->screenHeight()*0.15);
btnPersonalInfo->setIconSize(QSize(btnPersonalInfo->height()*0.7, btnPersonalInfo->height()*0.7));
btnPersonalInfo->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
btnPersonalInfo->setStyleSheet("font:16px; color:white;background-color:rgba(0,0,0,0)");
connect(btnPersonalInfo, SIGNAL(clicked()), SLOT(on_btnPersonal_clicked()));
QVBoxLayout* themeLayout = new QVBoxLayout;
themeLayout->addWidget(btnPersonalInfo);
themeLayout->setMargin(0);
themeWidget->setLayout(themeLayout);
//设置
btnSetting = new GroupButton;
btnSetting->setStyleSheet(SheetStyle::GROUPBUTTON_BOTTOMBORDER);
QPixmap settingPixmap(ImagePath::SETTING);
this->setGroupButton(btnSetting, settingPixmap, tr("设置"));
connect(btnSetting, SIGNAL(clicked()), SLOT(on_btnSetting_clicked()));
QVBoxLayout* vblTotalLayout = new QVBoxLayout;
vblTotalLayout->addWidget(themeWidget);
vblTotalLayout->addSpacing(this->screenHeight()*0.026);
vblTotalLayout->addWidget(btnSetting);
vblTotalLayout->setAlignment(Qt::AlignTop);
vblTotalLayout->setMargin(0);
vblTotalLayout->setSpacing(0);
this->setBodyPartLayout(vblTotalLayout);
//屏幕触摸滚动设置
this->setBodyScreenHeight(this->scrollAreaHasBottomBarHeight());
this->installScrollViewportArea();
this->loadLocalData(curAccountID);
}
示例8: addLabel
QLabel * addLabel(QHBoxLayout * hboxLayout, QPixmap * pixmap) {
QLabel * label = new QLabel();
label->setObjectName("iconLabel");
label->setAutoFillBackground(true);
label->setPixmap(*pixmap);
label->setFixedSize(pixmap->size());
hboxLayout->addWidget(label);
hboxLayout->addSpacing(IconSpace);
return label;
}
示例9: createWidget
QWidget* MenuTitleItem::createWidget(QWidget *parent)
{
QLabel* l = new QLabel(s, parent);
l->setAlignment(Qt::AlignCenter);
l->setAutoFillBackground(true);
//QPalette palette;
//palette.setColor(label->backgroundRole(), c);
//l->setPalette(palette);
l->setBackgroundRole(QPalette::Dark);
return l;
}
示例10: QLabel
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
Q_UNUSED(option);
QLabel *label = new QLabel(parent);
label->setAutoFillBackground(true);
label->setTextInteractionFlags(Qt::TextSelectableByMouse
| Qt::LinksAccessibleByMouse);
label->setText(index.data().toString());
return label;
}
示例11:
//! [4]
QLabel *IconPreviewArea::createPixmapLabel()
{
QLabel *label = new QLabel;
label->setEnabled(false);
label->setAlignment(Qt::AlignCenter);
label->setFrameShape(QFrame::Box);
label->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
label->setBackgroundRole(QPalette::Base);
label->setAutoFillBackground(true);
label->setMinimumSize(132, 132);
return label;
}
示例12: blankKeyLabel
void DetailWindow::blankKeyLabel(){
deleteKeyLabels();
QLabel* dummyLabel = new QLabel();
QPalette pal = dummyLabel->palette();
pal.setColor(backgroundRole(), Qt::black);
dummyLabel->setPalette(pal);
dummyLabel->setAutoFillBackground(true);
dummyLabel->setMinimumHeight(20);
dummyLabel->setMaximumHeight(30);
dummyLabel->setToolTip(wrapToolTip(tr("Drag an audio file onto the window.")));
ui->horizontalLayout_keyLabels->addWidget(dummyLabel);
keyLabels.push_back(dummyLabel);
}
示例13: addOptionalMessage
/** Add the optional message in a light yellow box to the layout
*
* @param mainLay :: layout
*/
void AlgorithmDialog::addOptionalMessage(QVBoxLayout *mainLay) {
QLabel *inputMessage = new QLabel(this);
inputMessage->setFrameStyle(QFrame::Panel | QFrame::Sunken);
QPalette pal = inputMessage->palette();
pal.setColor(inputMessage->backgroundRole(),
QColor(255, 255, 224)); // Light yellow
pal.setColor(inputMessage->foregroundRole(), Qt::black);
inputMessage->setPalette(pal);
inputMessage->setAutoFillBackground(true);
inputMessage->setWordWrap(true);
inputMessage->setAlignment(Qt::AlignJustify);
inputMessage->setMargin(3);
inputMessage->setText(getOptionalMessage());
QHBoxLayout *msgArea = new QHBoxLayout;
msgArea->addWidget(inputMessage);
mainLay->addLayout(msgArea, 0);
}
示例14: ModelPanel
TelemetryCustomScreen::TelemetryCustomScreen(QWidget *parent, ModelData & model, FrSkyScreenData & screen, GeneralSettings & generalSettings, FirmwareInterface * firmware):
ModelPanel(parent, model, generalSettings, firmware),
ui(new Ui::TelemetryCustomScreen),
screen(screen)
{
ui->setupUi(this);
for (int l=0; l<4; l++) {
for (int c=0; c<firmware->getCapability(TelemetryCustomScreensFieldsPerLine); c++) {
fieldsCB[l][c] = new QComboBox(this);
fieldsCB[l][c]->setProperty("index", c + (l<<8));
ui->screenNumsLayout->addWidget(fieldsCB[l][c], l, c, 1, 1);
connect(fieldsCB[l][c], SIGNAL(currentIndexChanged(int)), this, SLOT(customFieldChanged(int)));
}
}
for (int l=0; l<4; l++) {
barsCB[l] = new QComboBox(this);
barsCB[l]->setProperty("index", l);
connect(barsCB[l], SIGNAL(currentIndexChanged(int)), this, SLOT(barSourceChanged(int)));
ui->screenBarsLayout->addWidget(barsCB[l], l, 0, 1, 1);
minSB[l] = new QDoubleSpinBox(this);
minSB[l]->setProperty("index", l);
connect(minSB[l], SIGNAL(valueChanged(double)), this, SLOT(barMinChanged(double)));
ui->screenBarsLayout->addWidget(minSB[l], l, 1, 1, 1);
QLabel * label = new QLabel(this);
label->setAutoFillBackground(false);
label->setStyleSheet(QString::fromUtf8("Background:qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(0, 0, 128, 255), stop:0.339795 rgba(0, 0, 128, 255), stop:0.339799 rgba(255, 255, 255, 255), stop:0.662444 rgba(255, 255, 255, 255),)\n"""));
label->setFrameShape(QFrame::Panel);
label->setFrameShadow(QFrame::Raised);
label->setAlignment(Qt::AlignCenter);
ui->screenBarsLayout->addWidget(label, l, 2, 1, 1);
maxSB[l] = new QDoubleSpinBox(this);
maxSB[l]->setProperty("index", l);
connect(maxSB[l], SIGNAL(valueChanged(double)), this, SLOT(barMaxChanged(double)));
ui->screenBarsLayout->addWidget(maxSB[l], l, 3, 1, 1);
}
disableMouseScrolling();
update();
}
示例15: AlignmentView
AlignmentView(Gui::Document* pcDocument, QWidget* parent, QGLWidget* shareWidget=0, Qt::WindowFlags wflags=0)
: AbstractSplitView(pcDocument, parent, wflags)
{
QSplitter* mainSplitter=0;
mainSplitter = new QSplitter(Qt::Horizontal, this);
_viewer.push_back(new View3DInventorViewer(mainSplitter, shareWidget));
_viewer.back()->setDocument(pcDocument);
_viewer.push_back(new View3DInventorViewer(mainSplitter, shareWidget));
_viewer.back()->setDocument(pcDocument);
QFrame* vbox = new QFrame(this);
QVBoxLayout* layout = new QVBoxLayout();
layout->setMargin(0);
layout->setSpacing(0);
vbox->setLayout(layout);
myLabel = new QLabel(this);
myLabel->setAutoFillBackground(true);
QPalette pal = myLabel->palette();
pal.setColor(QPalette::Window, Qt::darkGray);
pal.setColor(QPalette::WindowText, Qt::white);
myLabel->setPalette(pal);
mainSplitter->setPalette(pal);
myLabel->setAlignment(Qt::AlignCenter);
myLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
QFont font = myLabel->font();
font.setPointSize(14);
myLabel->setFont(font);
layout->addWidget(myLabel);
layout->addWidget(mainSplitter);
vbox->show();
setCentralWidget(vbox);
// apply the user settings
setupSettings();
static_cast<SoGroup*>(getViewer(0)->getSoRenderManager()->getSceneGraph())->
addChild(setupHeadUpDisplay(tr("Movable object")));
static_cast<SoGroup*>(getViewer(1)->getSoRenderManager()->getSceneGraph())->
addChild(setupHeadUpDisplay(tr("Fixed object")));
}