本文整理汇总了C++中QScrollArea::palette方法的典型用法代码示例。如果您正苦于以下问题:C++ QScrollArea::palette方法的具体用法?C++ QScrollArea::palette怎么用?C++ QScrollArea::palette使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QScrollArea
的用法示例。
在下文中一共展示了QScrollArea::palette方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createKMessageBox
int KMessageBox::createKMessageBox(KDialog *dialog, const QIcon &icon,
const QString &text, const QStringList &strlist,
const QString &ask, bool *checkboxReturn, Options options,
const QString &details, QMessageBox::Icon notifyType)
{
QWidget *mainWidget = new QWidget(dialog);
QVBoxLayout *mainLayout = new QVBoxLayout(mainWidget);
mainLayout->setSpacing(KDialog::spacingHint() * 2); // provide extra spacing
mainLayout->setMargin(0);
QHBoxLayout *hLayout = new QHBoxLayout();
hLayout->setMargin(0);
hLayout->setSpacing(-1); // use default spacing
mainLayout->addLayout(hLayout,5);
QLabel *iconLabel = new QLabel(mainWidget);
if (!icon.isNull()) {
QStyleOption option;
option.initFrom(mainWidget);
iconLabel->setPixmap(icon.pixmap(mainWidget->style()->pixelMetric(QStyle::PM_MessageBoxIconSize, &option, mainWidget)));
}
QVBoxLayout *iconLayout = new QVBoxLayout();
iconLayout->addStretch(1);
iconLayout->addWidget(iconLabel);
iconLayout->addStretch(5);
hLayout->addLayout(iconLayout,0);
hLayout->addSpacing(KDialog::spacingHint());
QLabel *messageLabel = new QLabel(text, mainWidget);
messageLabel->setOpenExternalLinks(options & KMessageBox::AllowLink);
Qt::TextInteractionFlags flags = Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard;
if (options & KMessageBox::AllowLink) {
flags |= Qt::LinksAccessibleByMouse | Qt::LinksAccessibleByKeyboard;
}
messageLabel->setTextInteractionFlags(flags);
QRect desktop = KGlobalSettings::desktopGeometry(dialog);
bool usingSqueezedTextLabel = false;
if (messageLabel->sizeHint().width() > desktop.width() * 0.5) {
// enable automatic wrapping of messages which are longer than 50% of screen width
messageLabel->setWordWrap(true);
// display a text widget with scrollbar if still too wide
usingSqueezedTextLabel = messageLabel->sizeHint().width() > desktop.width() * 0.85;
if (usingSqueezedTextLabel)
{
delete messageLabel;
messageLabel = new KSqueezedTextLabel(text, mainWidget);
messageLabel->setOpenExternalLinks(options & KMessageBox::AllowLink);
messageLabel->setTextInteractionFlags(flags);
}
}
QPalette messagePal(messageLabel->palette());
messagePal.setColor(QPalette::Window, Qt::transparent);
messageLabel->setPalette(messagePal);
bool usingScrollArea=desktop.height() / 3 < messageLabel->sizeHint().height();
if (usingScrollArea)
{
QScrollArea* messageScrollArea = new QScrollArea(mainWidget);
messageScrollArea->setWidget(messageLabel);
messageScrollArea->setFrameShape(QFrame::NoFrame);
messageScrollArea->setWidgetResizable(true);
QPalette scrollPal(messageScrollArea->palette());
scrollPal.setColor(QPalette::Window, Qt::transparent);
messageScrollArea->viewport()->setPalette(scrollPal);
hLayout->addWidget(messageScrollArea,5);
}
else
hLayout->addWidget(messageLabel,5);
const bool usingListWidget=!strlist.isEmpty();
if (usingListWidget) {
// enable automatic wrapping since the listwidget has already a good initial width
messageLabel->setWordWrap(true);
QListWidget *listWidget = new QListWidget(mainWidget);
listWidget->addItems(strlist);
QStyleOptionViewItem styleOption;
styleOption.initFrom(listWidget);
QFontMetrics fm(styleOption.font);
int w = listWidget->width();
Q_FOREACH(const QString &str, strlist) {
w = qMax(w, fm.width(str));
}
const int borderWidth = listWidget->width() - listWidget->viewport()->width() + listWidget->verticalScrollBar()->height();
w += borderWidth;
if (w > desktop.width() * 0.85) { // limit listWidget size to 85% of screen width
w = qRound(desktop.width() * 0.85);
}
listWidget->setMinimumWidth(w);
mainLayout->addWidget(listWidget,usingScrollArea?10:50);
listWidget->setSelectionMode(QListWidget::NoSelection);
messageLabel->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Minimum);
//.........这里部分代码省略.........
示例2: palette
MainWidget::MainWidget(QWidget *parent) :
QWidget(parent)
{
//init color palette for variables
VariableColorPalette palette(QColor(50,100,200));
preview = new CubeMapPreview(500);
loader = new CubeMapLoader();
curveEditor = new CurveEditor(this);
curveEditor->setViewScale(0.1,-1);
setEditorRange(100);
curveEditor->setSnap(1,0);
curveEditor->setCurrentFrame(0);
//create and init variables
CurveVariable * pitch = new CurveVariable("Pitch");
CurveVariable * yaw = new CurveVariable("Yaw");
CurveVariable * roll = new CurveVariable("Roll");
CurveVariable * zoom = new CurveVariable("Zoom");
CurveVariable * fov = new CurveVariable("Fov",180);
CurveVariable * frame = new CurveVariable("Cubemap",0);
//add variables to key frames watcher
KeyFrames * keyFrames = KeyFrames::getInstance();
keyFrames->addVariable(pitch);
keyFrames->addVariable(zoom);
keyFrames->addVariable(roll);
keyFrames->addVariable(fov);
keyFrames->addVariable(yaw);
keyFrames->addVariable(frame);
curveEditor->addVariable(pitch);
curveEditor->addVariable(yaw);
curveEditor->addVariable(roll);
curveEditor->addVariable(zoom);
curveEditor->addVariable(fov);
curveEditor->addVariable(frame);
preview->setPitchVar(pitch);
preview->setFovVar(fov);
preview->setYawVar(yaw);
preview->setRollVar(roll);
preview->setZoomVar(zoom);
loader->setFrameVar(frame);
//setup time line
timeLine = new TimeLine(this);
//init IO module
importExport = new IOWidget(loader, timeLine, this);
//let the timeline know that a frame has been keyed/un keyed
connect(pitch,SIGNAL(changed(float,float)), timeLine, SLOT(update()));
connect(yaw,SIGNAL(changed(float,float)), timeLine, SLOT(update()));
connect(roll,SIGNAL(changed(float,float)), timeLine, SLOT(update()));
connect(zoom,SIGNAL(changed(float,float)), timeLine, SLOT(update()));
connect(fov,SIGNAL(changed(float,float)), timeLine, SLOT(update()));
connect(frame,SIGNAL(changed(float,float)), timeLine, SLOT(update()));
//update preview when cube map changes
connect(loader,SIGNAL(faceChanged(QImage *,CubeFace)),preview,SLOT(setFace(QImage *, CubeFace)));
//tells the cube map loader to load the cube map corresponding to the new frame
connect(timeLine,SIGNAL(frameChanged(float)),loader,SLOT(variablesValues(float)));
//tells the preview to display a new frame
connect(timeLine,SIGNAL(frameChanged(float)),preview,SLOT(variablesValues(float)));
//update the frame cursor of the curve editor
connect(timeLine,SIGNAL(frameChanged(float)),curveEditor,SLOT(setCurrentFrame(float)));
//Change the range of frames displayed by the curvor editor when the number of frames changes
connect(timeLine,SIGNAL(frameNumberChanged(int)), this, SLOT(setEditorRange(int)));
//Refresh preview when curves have been edited
connect(curveEditor,SIGNAL(curvesChanged(float, float)),preview,SLOT(refreshVariablesValues(float, float)));
//connect(timeLine,SIGNAL(frameChanged(float)),preview,SLOT(refresh()));
//stop playback if the user interacts with the preview
connect(preview,SIGNAL(previewChanged()),timeLine,SLOT(stop()));
QTabWidget * tabWidget = new QTabWidget(this);
tabWidget->addTab(loader,"Cube&map");
tabWidget->addTab(curveEditor,"Curve &Editor");
tabWidget->addTab(importExport,"E&xport");
QScrollArea * previewScroll = new QScrollArea(this);
previewScroll->setWidget(preview);
previewScroll->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
QPalette pal = previewScroll->palette();
pal.setColor(QPalette::Background,Qt::black);
previewScroll->setPalette(pal);
//.........这里部分代码省略.........