本文整理汇总了C++中QLabel::font方法的典型用法代码示例。如果您正苦于以下问题:C++ QLabel::font方法的具体用法?C++ QLabel::font怎么用?C++ QLabel::font使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QLabel
的用法示例。
在下文中一共展示了QLabel::font方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AlignmentView
AlignmentView(Gui::Document* pcDocument, QWidget* parent, Qt::WFlags wflags=0)
: AbstractSplitView(pcDocument, parent, wflags)
{
QSplitter* mainSplitter=0;
mainSplitter = new QSplitter(Qt::Horizontal, this);
_viewer.push_back(new View3DInventorViewer(mainSplitter));
_viewer.push_back(new View3DInventorViewer(mainSplitter));
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)->getSceneManager()->getSceneGraph())->
addChild(setupHeadUpDisplay(tr("Movable object")));
static_cast<SoGroup*>(getViewer(1)->getSceneManager()->getSceneGraph())->
addChild(setupHeadUpDisplay(tr("Fixed object")));
}
示例2: QMenu
RSSWidget::RSSWidget(const QMap< KUrl, QString > &map, QWidget *parent)
: QMenu(parent)
, m_map(map)
{
setAttribute(Qt::WA_DeleteOnClose);
setFixedWidth(350);
QFormLayout *layout = new QFormLayout(this);
// Title
QLabel *title = new QLabel(this);
title->setText(i18n("Subscribe to RSS Feeds"));
QFont f = title->font();
f.setBold(true);
title->setFont(f);
layout->addRow(title);
// Agregators
QLabel *agregator = new QLabel(this);
agregator->setText(i18n("Aggregator:"));
m_agregators = new KComboBox(this);
m_agregators->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
m_agregators->addItem(KIcon("akregator"), QString("Akregator"));
m_agregators->addItem(rApp->iconManager()->iconForUrl(KUrl("http://google.com/reader")), i18n("Google Reader"));
layout->addRow(agregator, m_agregators);
// Feeds List
QLabel *feed = new QLabel(this);
feed->setText(i18n("Feed:"));
m_feeds = new KComboBox(this);
m_feeds->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
Q_FOREACH(const QString & title, m_map)
{
m_feeds->addItem(title);
}
示例3: tr
pluginBrowser::pluginBrowser( QWidget * _parent ) :
SideBarWidget( tr( "Instrument plugins" ),
embed::getIconPixmap( "plugins" ).transformed( QTransform().rotate( 90 ) ), _parent )
{
setWindowTitle( tr( "Instrument browser" ) );
m_view = new QWidget( contentParent() );
//m_view->setFrameShape( QFrame::NoFrame );
addContentWidget( m_view );
QVBoxLayout * view_layout = new QVBoxLayout( m_view );
view_layout->setMargin( 5 );
view_layout->setSpacing( 5 );
QLabel * hint = new QLabel( tr( "Drag an instrument "
"into either the Song-Editor, the "
"Beat+Bassline Editor or into an "
"existing instrument track." ),
m_view );
hint->setFont( pointSize<8>( hint->font() ) );
hint->setWordWrap( true );
view_layout->addWidget( hint );
Plugin::getDescriptorsOfAvailPlugins( m_pluginDescriptors );
qSort( m_pluginDescriptors.begin(), m_pluginDescriptors.end(), pluginBefore );
for( Plugin::DescriptorList::ConstIterator it = m_pluginDescriptors.begin();
it != m_pluginDescriptors.end(); ++it )
{
if( it->type == Plugin::Instrument )
{
pluginDescWidget * p = new pluginDescWidget( *it, m_view );
p->show();
view_layout->addWidget( p );
}
}
view_layout->addStretch();
show();
}
示例4: lineRow
void
PanelsWidget::addPanel( PanelData *panel )
{
const int headerRow = layout_->rowCount();
// icon:
if (!panel->icon().isNull()) {
QLabel *iconLabel = new QLabel(root_);
iconLabel->setPixmap( panel->icon().pixmap( Constants::ICON_SIZE, Constants::ICON_SIZE ) );
iconLabel->setContentsMargins( 0, Constants::ABOVE_HEADING_MARGIN, 0, 0 );
layout_->addWidget( iconLabel, headerRow, 0, /*rowSpan=*/3, /*colSpan=*/1, Qt::AlignTop | Qt::AlignHCenter );
}
// name:
QLabel *nameLabel = new QLabel(root_);
nameLabel->setText( panel->displayName() );
QPalette palette = nameLabel->palette();
for (int i = QPalette::Active; i < QPalette::NColorGroups; ++i ) {
QColor foregroundColor = palette.color(QPalette::ColorGroup(i), QPalette::Foreground);
foregroundColor.setAlpha(110);
palette.setBrush(QPalette::ColorGroup(i), QPalette::Foreground, foregroundColor);
}
nameLabel->setPalette(palette);
nameLabel->setContentsMargins(0, Constants::ABOVE_HEADING_MARGIN, 0, 0);
QFont f = nameLabel->font();
f.setBold(true);
f.setPointSizeF(f.pointSizeF() * 1.6);
nameLabel->setFont(f);
layout_->addWidget(nameLabel, headerRow, 1, 1, 1, Qt::AlignVCenter | Qt::AlignLeft);
// line:
const int lineRow(headerRow + 1);
QWidget *line = new OnePixelBlackLine(root_);
layout_->addWidget(line, lineRow, 1, 1, -1, Qt::AlignTop);
// add the widget:
const int widgetRow(lineRow + 1);
addPanelWidget(panel, widgetRow);
layout_->setRowStretch( lineRow + 1, 100 );
}
示例5: QHBoxLayout
QmitkPaintbrushToolGUI::QmitkPaintbrushToolGUI()
:QmitkToolGUI(),
m_Slider(NULL)
{
// create the visible widgets
QBoxLayout* layout = new QHBoxLayout( this );
this->setContentsMargins( 0, 0, 0, 0 );
QLabel* label = new QLabel( "Size ", this );
QFont f = label->font();
f.setBold(false);
label->setFont( f );
layout->addWidget(label);
m_SizeLabel = new QLabel( " 10", this );
f = m_SizeLabel->font();
f.setBold(false);
m_SizeLabel->setFont( f );
layout->addWidget(m_SizeLabel);
//m_Slider = new QSlider( 1, 50, 1, 10, Qt::Horizontal, this );
m_Slider = new QSlider( Qt::Horizontal, this );
m_Slider->setMinimum(1);
m_Slider->setMaximum(50);
m_Slider->setPageStep(1);
m_Slider->setValue(10);
connect( m_Slider, SIGNAL(valueChanged(int)), this, SLOT(OnSliderValueChanged(int)));
layout->addWidget( m_Slider );
/*
m_Frame = new QFrame( this );
m_Frame->setMinimumSize( QSize(50, 50) );
m_Frame->setFrameStyle( QFrame::Box || QFrame::Plain );
m_Frame->show();
layout->addWidget( m_Frame );
*/
connect( this, SIGNAL(NewToolAssociated(mitk::Tool*)), this, SLOT(OnNewToolAssociated(mitk::Tool*)) );
}
示例6: QDialog
AboutDialog::AboutDialog(QWidget *parent)
: QDialog(parent)
{
setWindowTitle(tr("Bluecherry Client - About"));
setFixedSize(500, 400);
setModal(true);
QGridLayout *layout = new QGridLayout(this);
QLabel *logo = new QLabel;
logo->setPixmap(QPixmap(QLatin1String(":/images/logo.png"))
.scaled(130, 130, Qt::KeepAspectRatio, Qt::SmoothTransformation));
logo->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
layout->addWidget(logo, 0, 0);
QLabel *text = new QLabel;
text->setText(tr("Bluecherry DVR Client<br>Version %1").arg(QApplication::applicationVersion()));
text->setAlignment(Qt::AlignHCenter | Qt::AlignTop);
QFont font = text->font();
font.setPixelSize(15);
text->setFont(font);
layout->addWidget(text, 0, 1);
layout->setColumnStretch(1, 1);
QTextBrowser *license = new QTextBrowser;
license->setHtml(getLicenseText());
license->setStyleSheet(QLatin1String("font-size: 12px"));
license->setReadOnly(true);
license->setOpenExternalLinks(true);
license->setTabChangesFocus(true);
layout->addWidget(license, 1, 0, 1, 2);
font = QFont();
font.setStyleHint(QFont::SansSerif);
font.setPixelSize(13);
license->setFont(font);
}
示例7: fontMetrics
LineEditDialog::LineEditDialog(QString title, QWidget* parent) : QDialog(parent, Qt::Popup) {
QLabel* label = new QLabel(title);
edit = new QLineEdit(this);
// edit->setGeometry(1, 1, 150, 23);
connect(edit, SIGNAL(editingFinished()), this, SLOT(accept()));
QVBoxLayout* layout = new QVBoxLayout(this);
layout->setMargin(4);
layout->addWidget(label);
layout->addWidget(edit);
QFrame* frame = new QFrame();
frame->setFrameStyle(QFrame::Panel | QFrame::Raised);
frame->setLineWidth(2);
frame->setLayout(layout);
QVBoxLayout* mainLayout = new QVBoxLayout();
mainLayout->setMargin(0);
mainLayout->addWidget(frame);
setLayout(mainLayout);
QFontMetrics fontMetrics(label->font());
const int width = std::max(200, fontMetrics.boundingRect(title).width() + 20), height = 50;
QDesktopWidget desk;
int screenWidth = 0, screenHeight = 0;
for (int iScreen = 0; iScreen <= desk.screenNumber(QCursor::pos()); ++iScreen) {
screenWidth += desk.screenGeometry(iScreen).width();
screenHeight += desk.screenGeometry(iScreen).height();
}
setGeometry(std::min(screenWidth - width - 10, QCursor::pos().x()),
std::min(screenHeight - height - 10, QCursor::pos().y()),
width, height);
edit->setFocus();
}
示例8: CodeStyleEditorWidget
CodeStyleEditor::CodeStyleEditor(ICodeStylePreferencesFactory *factory,
ICodeStylePreferences *codeStyle, QWidget *parent)
: CodeStyleEditorWidget(parent),
m_factory(factory),
m_codeStyle(codeStyle)
{
m_layout = new QVBoxLayout(this);
auto selector = new CodeStyleSelectorWidget(factory, this);
selector->setCodeStyle(codeStyle);
m_preview = new SnippetEditorWidget(this);
DisplaySettings displaySettings = m_preview->displaySettings();
displaySettings.m_visualizeWhitespace = true;
m_preview->setDisplaySettings(displaySettings);
QString groupId = factory->snippetProviderGroupId();
SnippetProvider::decorateEditor(m_preview, groupId);
QLabel *label = new QLabel(
tr("Edit preview contents to see how the current settings "
"are applied to custom code snippets. Changes in the preview "
"do not affect the current settings."), this);
QFont font = label->font();
font.setItalic(true);
label->setFont(font);
label->setWordWrap(true);
m_layout->addWidget(selector);
m_layout->addWidget(m_preview);
m_layout->addWidget(label);
connect(codeStyle, &ICodeStylePreferences::currentTabSettingsChanged,
this, &CodeStyleEditor::updatePreview);
connect(codeStyle, &ICodeStylePreferences::currentValueChanged,
this, &CodeStyleEditor::updatePreview);
connect(codeStyle, &ICodeStylePreferences::currentPreferencesChanged,
this, &CodeStyleEditor::updatePreview);
m_preview->setCodeStyle(m_codeStyle);
m_preview->setPlainText(factory->previewText());
updatePreview();
}
示例9: addLibraries
static void addLibraries(QGridLayout *layout, const std::string &name, const std::list<RsLibraryInfo> &libraries)
{
int row = layout->rowCount();
QLabel *label = new QLabel(QString::fromUtf8(name.c_str()));
label->setTextInteractionFlags(label->textInteractionFlags() | Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard);
layout->addWidget(label, row++, 0, 1, 3);
QFont font = label->font();
font.setBold(true);
label->setFont(font);
std::list<RsLibraryInfo>::const_iterator libraryIt;
for (libraryIt = libraries.begin(); libraryIt != libraries.end(); ++libraryIt) {
label = new QLabel(QString::fromUtf8(libraryIt->mName.c_str()));
label->setTextInteractionFlags(label->textInteractionFlags() | Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard);
layout->addWidget(label, row, 0);
label->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
label = new QLabel(QString::fromUtf8(libraryIt->mVersion.c_str()));
label->setTextInteractionFlags(label->textInteractionFlags() | Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard);
layout->addWidget(label, row++, 1);
}
}
示例10: AddFont
void OBSPropertiesView::AddFont(obs_property_t *prop, QFormLayout *layout,
QLabel *&label)
{
const char *name = obs_property_name(prop);
obs_data_t *font_obj = obs_data_get_obj(settings, name);
const char *face = obs_data_get_string(font_obj, "face");
const char *style = obs_data_get_string(font_obj, "style");
QPushButton *button = new QPushButton;
QLabel *fontLabel = new QLabel;
QFont font;
font = fontLabel->font();
MakeQFont(font_obj, font);
button->setText(QTStr("Basic.PropertiesWindow.SelectFont"));
fontLabel->setFrameStyle(QFrame::Sunken | QFrame::Panel);
fontLabel->setFont(font);
fontLabel->setText(QString("%1 %2").arg(face, style));
fontLabel->setAlignment(Qt::AlignCenter);
QHBoxLayout *subLayout = new QHBoxLayout;
subLayout->setContentsMargins(0, 0, 0, 0);
subLayout->addWidget(fontLabel);
subLayout->addWidget(button);
WidgetInfo *info = new WidgetInfo(this, prop, fontLabel);
connect(button, SIGNAL(clicked()), info, SLOT(ControlChanged()));
children.emplace_back(info);
label = new QLabel(QT_UTF8(obs_property_description(prop)));
layout->addRow(label, subLayout);
obs_data_release(font_obj);
}
示例11: SetPrecision
void ParamWidget::SetPrecision(const QString& name, int digits, int decimal_places)
{
QWidget* widget = GetWidget(name);
QSlider* slider = dynamic_cast<QSlider*>(widget);
if (slider) {
QLabel* label = slider->property("param_widget_label").value<QLabel*>();
if (label) {
const QFont& font = label->font();
QFontMetrics font_metrics(font);
QString sample_text;
for (int i = 0; i < digits; ++i) {
sample_text.append('9');
}
if (decimal_places) {
sample_text.append('.');
}
const int width = font_metrics.width(sample_text);
QString format_str;
format_str.sprintf("%%%d.%df", digits, decimal_places);
label->setProperty("format_str", format_str);
label->setFixedWidth(width);
}
}
}
示例12: font
InspectorNote::InspectorNote(QWidget* parent)
: InspectorBase(parent)
{
b.setupUi(addWidget());
s.setupUi(addWidget());
c.setupUi(addWidget());
n.setupUi(addWidget());
static const NoteHead::Group heads[] = {
NoteHead::Group::HEAD_NORMAL,
NoteHead::Group::HEAD_CROSS,
NoteHead::Group::HEAD_DIAMOND,
NoteHead::Group::HEAD_TRIANGLE,
NoteHead::Group::HEAD_SLASH,
NoteHead::Group::HEAD_XCIRCLE,
NoteHead::Group::HEAD_DO,
NoteHead::Group::HEAD_RE,
NoteHead::Group::HEAD_MI,
NoteHead::Group::HEAD_FA,
NoteHead::Group::HEAD_SOL,
NoteHead::Group::HEAD_LA,
NoteHead::Group::HEAD_TI,
NoteHead::Group::HEAD_BREVIS_ALT
};
//
// fix order of note heads
//
for (unsigned i = 0; i < sizeof(heads)/sizeof(*heads); ++i) {
n.noteHeadGroup->addItem(qApp->translate("noteheadnames", NoteHead::groupToGroupName(heads[i])));
n.noteHeadGroup->setItemData(i, QVariant(int(heads[i])));
}
// noteHeadType starts at -1: correct values and count one item more (HEAD_AUTO)
for (int i = 0; i <= int(NoteHead::Type::HEAD_TYPES); ++i)
n.noteHeadType->setItemData(i, i-1);
iList = {
{ P_ID::COLOR, 0, 0, b.color, b.resetColor },
{ P_ID::VISIBLE, 0, 0, b.visible, b.resetVisible },
{ P_ID::USER_OFF, 0, 0, b.offsetX, b.resetX },
{ P_ID::USER_OFF, 1, 0, b.offsetY, b.resetY },
{ P_ID::SMALL, 0, 0, n.small, n.resetSmall },
{ P_ID::HEAD_GROUP, 0, 0, n.noteHeadGroup, n.resetNoteHeadGroup },
{ P_ID::HEAD_TYPE, 0, 0, n.noteHeadType, n.resetNoteHeadType },
{ P_ID::MIRROR_HEAD, 0, 0, n.mirrorHead, n.resetMirrorHead },
{ P_ID::DOT_POSITION, 0, 0, n.dotPosition, n.resetDotPosition },
{ P_ID::PLAY, 0, 0, n.play, n.resetPlay },
{ P_ID::TUNING, 0, 0, n.tuning, n.resetTuning },
{ P_ID::VELO_TYPE, 0, 0, n.velocityType, n.resetVelocityType },
{ P_ID::VELO_OFFSET, 0, 0, n.velocity, n.resetVelocity },
{ P_ID::FIXED, 0, 0, n.fixed, n.resetFixed },
{ P_ID::FIXED_LINE, 0, 0, n.fixedLine, n.resetFixedLine },
{ P_ID::USER_OFF, 0, 1, c.offsetX, c.resetX },
{ P_ID::USER_OFF, 1, 1, c.offsetY, c.resetY },
{ P_ID::SMALL, 0, 1, c.small, c.resetSmall },
{ P_ID::NO_STEM, 0, 1, c.stemless, c.resetStemless },
{ P_ID::STEM_DIRECTION, 0, 1, c.stemDirection, c.resetStemDirection },
{ P_ID::LEADING_SPACE, 0, 2, s.leadingSpace, s.resetLeadingSpace },
};
mapSignals();
//
// Select
//
QLabel* l = new QLabel;
l->setText(tr("Select"));
QFont font(l->font());
font.setBold(true);
l->setFont(font);
l->setAlignment(Qt::AlignHCenter);
_layout->addWidget(l);
QFrame* f = new QFrame;
f->setFrameStyle(QFrame::HLine | QFrame::Raised);
f->setLineWidth(2);
_layout->addWidget(f);
QHBoxLayout* hbox = new QHBoxLayout;
dot1 = new QToolButton(this);
dot1->setText(tr("Dot1"));
dot1->setEnabled(false);
hbox->addWidget(dot1);
dot2 = new QToolButton(this);
dot2->setText(tr("Dot2"));
dot2->setEnabled(false);
hbox->addWidget(dot2);
dot3 = new QToolButton(this);
dot3->setText(tr("Dot3"));
dot3->setEnabled(false);
hbox->addWidget(dot3);
_layout->addLayout(hbox);
hbox = new QHBoxLayout;
hook = new QToolButton(this);
hook->setText(tr("Hook"));
hook->setEnabled(false);
//.........这里部分代码省略.........
示例13: QDialogButtonBox
InDevelopmentWarning::InDevelopmentWarning(QWidget* parent)
: QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint)
{
QWidget* container = new QWidget(this);
QDialogButtonBox* std_buttons =
new QDialogButtonBox(QDialogButtonBox::Cancel, Qt::Horizontal, this);
QLabel* heading = new QLabel(container);
QLabel* icon = new QLabel(container);
QLabel* body = new QLabel(container);
QCommandLinkButton* btn_dolphinwx = new QCommandLinkButton(
tr("Run DolphinWX Instead"), tr("Recommended for normal users"), container);
QCommandLinkButton* btn_run = new QCommandLinkButton(tr("Use DolphinQt Anyway"), container);
container->setForegroundRole(QPalette::Text);
container->setBackgroundRole(QPalette::Base);
container->setAutoFillBackground(true);
std_buttons->setContentsMargins(10, 0, 10, 0);
QFont heading_font{heading->font()};
heading_font.setPointSizeF(heading_font.pointSizeF() * 1.5);
heading->setFont(heading_font);
heading->setText(tr("DolphinQt Experimental GUI"));
heading->setForegroundRole(QPalette::Text);
heading->setAlignment(Qt::AlignTop | Qt::AlignLeft);
icon->setPixmap(style()->standardPixmap(QStyle::SP_MessageBoxWarning, nullptr, this));
icon->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
QString body_text = tr(
"<p>DolphinQt is a new experimental GUI that is eventually intended to replace "
"the current GUI based on wxWidgets. The implementation is <b>very "
"incomplete</b>, even basic functionality like changing settings and "
"attaching gamepads may be missing or not work at all.</p>\n"
"<p>Only developers working on the DolphinQt implementation should use it at "
"the present time; normal users are recommended to continue using the "
"older DolphinWX GUI for the time being.</p>\n"
"<p><big><b>Bug Reports:</b></big> At the current time there is no point making bug reports "
"about the DolphinQt GUI as the list of what is broken is much longer "
"than the list of things that work.</p>\n");
body->setText(body_text);
body->setWordWrap(true);
body->setForegroundRole(QPalette::Text);
body->setAlignment(Qt::AlignTop | Qt::AlignLeft);
body->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
btn_dolphinwx->setDefault(true);
connect(btn_dolphinwx, &QCommandLinkButton::clicked, this, [this](bool) {
if (!LaunchDolphinWX())
QMessageBox::critical(
this, tr("Failed to launch"),
tr("Could not start DolphinWX. Check for dolphin.exe in the installation directory."));
reject();
});
connect(btn_run, &QCommandLinkButton::clicked, this, [this](bool) { accept(); });
connect(std_buttons->button(QDialogButtonBox::Cancel), &QPushButton::clicked, this,
[this](bool) { reject(); });
QVBoxLayout* body_column = new QVBoxLayout();
body_column->addWidget(heading);
body_column->addSpacing(10);
body_column->addWidget(body);
body_column->addWidget(btn_dolphinwx);
body_column->addSpacing(10);
body_column->addWidget(btn_run);
body_column->setMargin(0);
body_column->setSpacing(0);
QHBoxLayout* icon_layout = new QHBoxLayout(container);
icon_layout->addWidget(icon, 0, Qt::AlignTop);
icon_layout->addLayout(body_column);
icon_layout->setContentsMargins(15, 10, 10, 10);
icon_layout->setSpacing(15);
QVBoxLayout* top_layout = new QVBoxLayout(this);
top_layout->addWidget(container);
top_layout->addWidget(std_buttons);
top_layout->setSpacing(10);
top_layout->setContentsMargins(0, 0, 0, 10);
setWindowIcon(Resources::GetMisc(Resources::LOGO_SMALL));
setWindowTitle(tr("DolphinQt2 Experimental GUI"));
setMinimumSize(460, 320);
resize(minimumSizeHint());
}
示例14: setScores
void ScoreBrowser::setScores(QFileInfoList& s)
{
qDeleteAll(scoreLists);
scoreLists.clear();
QVBoxLayout* l = static_cast<QVBoxLayout*>(scoreList->layout());
while (l->count())
l->removeItem(l->itemAt(0));
ScoreListWidget* sl = 0;
QStringList filter = { "*.mscz" };
if (_showCustomCategory)
std::sort(s.begin(), s.end(), [](QFileInfo a, QFileInfo b)->bool { return a.fileName() < b.fileName(); });
QSet<QString> entries; //to avoid duplicates
for (const QFileInfo& fi : s) {
if (fi.isDir()) {
QString s(fi.fileName());
if (!s.isEmpty() && s[0].isNumber() && _stripNumbers)
s = s.mid(3);
s = s.replace('_', ' ');
QLabel* label = new QLabel(s);
QFont f = label->font();
f.setBold(true);
label->setFont(f);
static_cast<QVBoxLayout*>(l)->addWidget(label);
QDir dir(fi.filePath());
sl = createScoreList();
l->addWidget(sl);
unsigned count = 0; //nbr of entries added
for (const QFileInfo& fi : dir.entryInfoList(filter, QDir::Files, QDir::Name)){
if (entries.contains(fi.filePath()))
continue;
sl->addItem(genScoreItem(fi, sl));
count++;
entries.insert(fi.filePath());
}
if (count == 0) {
delete label;
delete sl;
}
sl = 0;
}
}
for (const QFileInfo& fi : s) {
if (fi.isFile()) {
QString s = fi.filePath();
if (entries.contains(s))
continue;
if (s.endsWith(".mscz") || s.endsWith(".mscx")) {
if (!sl) {
if (_showCustomCategory) {
QLabel* label = new QLabel(tr("Custom Templates"));
QFont f = label->font();
f.setBold(true);
label->setFont(f);
l->insertWidget(2,label);
}
sl = createScoreList();
l->insertWidget(3,sl);
}
sl->addItem(genScoreItem(fi, sl));
entries.insert(s);
}
}
}
}
示例15: tTestModule
tSonarTestDigital::tSonarTestDigital( tHAL& hal, tSonarMaster& SonarMaster, tSonarClient& SonarClient,
tSonarSettings& SonarSettings, QWidget* p ) :
tTestModule( p, "Sonar Test, Digital" )
, m_HAL( hal )
, m_SonarMaster( SonarMaster )
, m_SonarClient( SonarClient )
, m_SonarSettings( SonarSettings )
{
m_Depth = 0.0f;
m_Temp = 0.0f;
m_WaterSpeed = 0.0f;
m_Voltage = 0.0f;
m_DepthValid = false;
m_TempValid = false;
m_WaterSpeedValid = false;
m_VoltageValid = false;
m_pLayout = new QGridLayout();
m_pDigitalDepth = new QLineEdit( QString( "----" ) );
m_pTemp1 = new QLineEdit( QString( "----" ) );
m_pWaterSpeed = new QLineEdit( QString( "----" ) );
m_pVoltage = new QLineEdit( QString( "----" ) );
m_pDigitalDepth->setFocusPolicy( Qt::NoFocus );
m_pTemp1->setFocusPolicy( Qt::NoFocus );
m_pWaterSpeed->setFocusPolicy( Qt::NoFocus );
m_pVoltage->setFocusPolicy( Qt::NoFocus );
QString toggleBtnStr = m_HAL.PlatformId() == ePlatformStingray2 ? "Power" : "Down Arrow";
QLabel* pLabelInstructions = new QLabel( QString( "Enter to start test\n" + toggleBtnStr + " to toggle temperature" ) );
long fontheight = QFontMetrics( pLabelInstructions->font() ).height();
pLabelInstructions->setMaximumHeight( fontheight * 4 );
QLabel* pLabelDigitalDepth = new QLabel( QString( "Digital Depth (49ft to 51ft)" ) );
m_pLabelTemp1 = new QLabel( QString( "Temp 1 (9 F to 11 F)" ) );
// QLabel* pLabelTemp2 = new QLabel(QString("Temp 2:"));
QLabel* pLabelWaterSpeed = new QLabel( QString( "Water speed (59mph to 61mph)" ) );
QLabel* pLabelVoltage = new QLabel( QString( "Voltage (12.85V to 14.15V)" ) );
//
m_pLayout->addWidget( pLabelInstructions, 0, 0 );
m_pLayout->addWidget( pLabelDigitalDepth, 1, 0 );
m_pLayout->addWidget( m_pDigitalDepth, 1, 1 );
m_pLayout->addWidget( m_pLabelTemp1, 3, 0 );
m_pLayout->addWidget( m_pTemp1, 3, 1 );
m_pLayout->addWidget( pLabelWaterSpeed, 5, 0 );
m_pLayout->addWidget( m_pWaterSpeed, 5, 1 );
m_pLayout->addWidget( pLabelVoltage, 7, 0 );
m_pLayout->addWidget( m_pVoltage, 7, 1 );
setLayout( m_pLayout );
Connect( &m_SonarClient, SIGNAL( NewDepth( float, bool, float, bool ) ), this, SLOT( NewDepth( float, bool, float, bool ) ) );
#if defined(_WIN32) //Only turn this on for debugging, not on a real unit
Connect( &m_SonarSettings, SIGNAL( NewTemperature( float, bool, bool, SonarCommon::eWaterTemperatureInstance ) ), this, SLOT( NewTemperature( float, bool ) ) );
Connect( &m_SonarSettings, SIGNAL( NewSpeed( float, bool, bool ) ), this, SLOT( NewSpeed( float, bool ) ) );
#endif
Connect( &m_SonarMaster, SIGNAL( NewTemperature( float, bool, SonarCommon::eWaterTemperatureInstance ) ), this, SLOT( NewTemperature( float, bool ) ) );
Connect( &m_SonarMaster, SIGNAL( NewSpeed( float, bool ) ), this, SLOT( NewSpeed( float, bool ) ) );
m_ShowError = false;
m_TimerCount = 0;
m_TempTestIndex = 0;
startTimer( 100 );
}