本文整理汇总了C++中QLabel::setContentsMargins方法的典型用法代码示例。如果您正苦于以下问题:C++ QLabel::setContentsMargins方法的具体用法?C++ QLabel::setContentsMargins怎么用?C++ QLabel::setContentsMargins使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QLabel
的用法示例。
在下文中一共展示了QLabel::setContentsMargins方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QLabel
ConnectionBasicTab::ConnectionBasicTab(ConnectionSettings *settings) :
_settings(settings)
{
QLabel *connectionDescriptionLabel = new QLabel(
"Choose any connection name that will help you to identify this connection.");
connectionDescriptionLabel->setWordWrap(true);
connectionDescriptionLabel->setContentsMargins(0, -2, 0, 20);
QLabel *serverDescriptionLabel = new QLabel(
"Specify host and port of MongoDB server. Host can be either IP or domain name.");
serverDescriptionLabel->setWordWrap(true);
serverDescriptionLabel->setContentsMargins(0, -2, 0, 20);
_connectionName = new QLineEdit(_settings->connectionName());
_serverAddress = new QLineEdit(_settings->serverHost());
_serverPort = new QLineEdit(QString::number(_settings->serverPort()));
_serverPort->setFixedWidth(80);
QGridLayout *connectionLayout = new QGridLayout;
connectionLayout->addWidget(new QLabel("Name:"), 1, 0);
connectionLayout->addWidget(_connectionName, 1, 1, 1, 3);
connectionLayout->addWidget(connectionDescriptionLabel, 2, 1, 1, 3);
connectionLayout->addWidget(serverDescriptionLabel, 4, 1, 1, 3);
connectionLayout->addWidget(new QLabel("Address:"), 3, 0);
connectionLayout->addWidget(_serverAddress, 3, 1);
connectionLayout->addWidget(new QLabel(":"), 3, 2);
connectionLayout->addWidget(_serverPort, 3, 3);
connectionLayout->setAlignment(Qt::AlignTop);
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addLayout(connectionLayout);
setLayout(mainLayout);
_connectionName->setFocus();
}
示例2: rx
ConnectionBasicTab::ConnectionBasicTab(ConnectionSettings *settings) :
_settings(settings)
{
QLabel *connectionDescriptionLabel = new QLabel(
"Choose any connection name that will help you to identify this connection.");
connectionDescriptionLabel->setWordWrap(true);
connectionDescriptionLabel->setContentsMargins(0, -2, 0, 20);
QLabel *serverDescriptionLabel = new QLabel(
"Specify host and port of MongoDB server. Host can be either IP or domain name.");
serverDescriptionLabel->setWordWrap(true);
serverDescriptionLabel->setContentsMargins(0, -2, 0, 20);
_connectionName = new QLineEdit(QtUtils::toQString(_settings->connectionName()));
_serverAddress = new QLineEdit(QtUtils::toQString(_settings->serverHost()));
_serverPort = new QLineEdit(QString::number(_settings->serverPort()));
_serverPort->setFixedWidth(80);
QRegExp rx("\\d+");//(0-65554)
_serverPort->setValidator(new QRegExpValidator(rx, this));
_sslSupport = new QCheckBox("SSL support");
_sslSupport->setChecked(_settings->sslInfo()._sslSupport);
_sslPEMKeyFile = new QLineEdit(QtUtils::toQString(_settings->sslInfo()._sslPEMKeyFile));
#ifdef Q_OS_WIN
QRegExp pathx("([a-zA-Z]:)?([\\\\/][a-zA-Z0-9_.-]+)+[\\\\/]?");
#else
QRegExp pathx("^\\/?([\\d\\w\\.]+)(/([\\d\\w\\.]+))*\\/?$");
#endif // Q_OS_WIN
_sslPEMKeyFile->setValidator(new QRegExpValidator(pathx, this));
_selectFileB = new QPushButton("...");
_selectFileB->setFixedSize(20,20);
VERIFY(connect(_selectFileB, SIGNAL(clicked()), this, SLOT(setSslPEMKeyFile())));
QGridLayout *connectionLayout = new QGridLayout;
connectionLayout->addWidget(new QLabel("Name:"), 1, 0);
connectionLayout->addWidget(_connectionName, 1, 1, 1, 3);
connectionLayout->addWidget(connectionDescriptionLabel, 2, 1, 1, 3);
connectionLayout->addWidget(serverDescriptionLabel, 4, 1, 1, 3);
connectionLayout->addWidget(new QLabel("Address:"), 3, 0);
connectionLayout->addWidget(_serverAddress, 3, 1);
connectionLayout->addWidget(new QLabel(":"), 3, 2);
connectionLayout->addWidget(_serverPort, 3, 3);
connectionLayout->setAlignment(Qt::AlignTop);
connectionLayout->addWidget(_sslSupport, 5, 1);
connectionLayout->addWidget(_selectFileB, 5, 2);
connectionLayout->addWidget(_sslPEMKeyFile, 5, 3);
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addLayout(connectionLayout);
setLayout(mainLayout);
sslSupportStateChange(_sslSupport->checkState());
VERIFY(connect(_sslSupport,SIGNAL(stateChanged(int)),this,SLOT(sslSupportStateChange(int))));
_connectionName->setFocus();
}
示例3: QDialog
AboutDialog::AboutDialog(QWidget* parent)
: QDialog(parent)
{
setWindowTitle(tr("About Dolphin"));
setAttribute(Qt::WA_DeleteOnClose);
QString text = QStringLiteral("");
QString small = QStringLiteral("<p style='margin-top:0px; margin-bottom:0px; font-size:9pt;'>");
QString medium = QStringLiteral("<p style='margin-top:15px; font-size:11pt;'>");
text.append(QStringLiteral("<p style='font-size:50pt; font-weight:400; margin-bottom:0px;'>") +
tr("Dolphin") + QStringLiteral("</p>"));
text.append(QStringLiteral("<p style='font-size:18pt; margin-top:0px;'>%1</p>")
.arg(QString::fromUtf8(scm_desc_str)));
text.append(small + tr("Branch: ") + QString::fromUtf8(scm_branch_str) + QStringLiteral("</p>"));
text.append(small + tr("Revision: ") + QString::fromUtf8(scm_rev_git_str) + QStringLiteral("</p>"));
text.append(small + tr("Compiled: ") + QStringLiteral(__DATE__ " " __TIME__ "</p>"));
text.append(medium + tr("Check for updates: ") +
QStringLiteral("<a href='https://dolphin-emu.org/download'>dolphin-emu.org/download</a></p>"));
text.append(medium + tr("Dolphin is a free and open-source GameCube and Wii emulator.") + QStringLiteral("</p>"));
text.append(medium + tr("This software should not be used to play games you do not legally own.") + QStringLiteral("</p>"));
text.append(medium + QStringLiteral(
"<a href='https://github.com/dolphin-emu/dolphin/blob/master/license.txt'>%1</a> | "
"<a href='https://github.com/dolphin-emu/dolphin/graphs/contributors'>%2</a> | "
"<a href='https://forums.dolphin-emu.org/'>%3</a></p>"
).arg(tr("Licence")).arg(tr("Authors")).arg(tr("Support")));
QLabel* text_label = new QLabel(text);
text_label->setTextInteractionFlags(Qt::TextBrowserInteraction);
text_label->setOpenExternalLinks(true);
QLabel* copyright = new QLabel(tr(
"© 2003-%1 Dolphin Team. “GameCube” and “Wii” are"
" trademarks of Nintendo. Dolphin is not affiliated with Nintendo in any way."
).arg(QStringLiteral(__DATE__).right(4)));
QLabel* logo = new QLabel();
logo->setPixmap(Resources::GetMisc(Resources::LOGO_LARGE));
logo->setContentsMargins(30, 0, 30, 0);
QVBoxLayout* main_layout = new QVBoxLayout;
QHBoxLayout* h_layout = new QHBoxLayout;
setLayout(main_layout);
main_layout->addLayout(h_layout);
main_layout->addWidget(copyright);
copyright->setAlignment(Qt::AlignCenter);
copyright->setContentsMargins(0, 15, 0, 0);
h_layout->setAlignment(Qt::AlignLeft);
h_layout->addWidget(logo);
h_layout->addWidget(text_label);
}
示例4: createToolBars
void BitcoinGUI::createToolBars()
{
QToolBar *toolbar = addToolBar(tr("Tabs toolbar"));
toolbar->setObjectName("toolbar");
addToolBar(Qt::LeftToolBarArea,toolbar);
toolbar->setOrientation(Qt::Vertical);
toolbar->setFixedWidth(205);
toolbar->setMovable( false );
toolbar->setToolButtonStyle(Qt::ToolButtonTextOnly);
QLabel* header = new QLabel();
header->setMinimumSize(156,156);
header->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
header->setPixmap(QPixmap(":/images/header"));
header->setMaximumSize(156,156);
header->setContentsMargins(26,26,0,0);
header->setScaledContents(true);
toolbar->addWidget(header);
QLabel *l = new QLabel(this);
l->setPixmap(QPixmap(":/images/spacer"));
toolbar->addWidget(l);
toolbar->addAction(overviewAction);
toolbar->addAction(sendCoinsAction);
toolbar->addAction(receiveCoinsAction);
toolbar->addAction(historyAction);
toolbar->addAction(addressBookAction);
toolbar->setStyleSheet("#toolbar {background: transparent; text-align: center; color: black;padding-right: 30px;} QToolBar QToolButton:hover {background-color: transparent;} QToolBar QToolButton:selected {background-color: transparent;} QToolBar QToolButton:checked {background-color: transparent;} QToolBar QToolButton:pressed {background-color: transparent;} QToolBar QToolButton {font-family:Steps; font-size:15px; font-weight: bold; min-width:125px;max-width:125px; min-height:25px;max-height:25px; color: white; text-align: left; }");
}
示例5: initializeWidget
void ForgetPwdVerifyPage::initializeWidget()
{
//提示信息页面操作
hintMsgPage = new HintMsgPage(this);
hintMsgPage->hide();
connect(hintMsgPage, SIGNAL(submitClicked(bool)), this, SLOT(on_hintMsgPage(bool)));
//导航栏
QString strTitle = tr("验 证");
QString strLeftBtn = tr("取消");
QPixmap leftArrowsPixmap(ImagePath::NAVIGATION_LEFT_ARROWS);
navigationBar = new NavigationBar(this);
navigationBar->setTitleText(strTitle);
navigationBar->setLeftText(strLeftBtn);
navigationBar->setLeftPixMap(leftArrowsPixmap);
connect(navigationBar, SIGNAL(leftClicked()), this, SLOT(on_btnPrePage_clicked()));
QHBoxLayout* pHLTop = new QHBoxLayout();
pHLTop->addWidget(navigationBar);
pHLTop->setSpacing(0);
pHLTop->setMargin(0);
this->setTopbarLayout(pHLTop);
//验证部分
QLabel* lblMsgHint = new QLabel(this);
lblMsgHint->setText(tr("已发送验证码到您的邮箱"));
lblMsgHint->setFixedHeight(this->screenHeight()*0.05);
lblMsgHint->setAlignment(Qt::AlignLeft);
lblMsgHint->setContentsMargins(this->screenWidth()*0.02, 0, this->screenWidth()*0.02, 0);
lblMsgHint->setStyleSheet("color:rgb(122,123,128); font:16px;");
editValidate = new QLineEdit(this);
editValidate->setFixedHeight(this->screenHeight()*0.08);
editValidate->setPlaceholderText(tr("输入6位验证码"));
editValidate->setStyleSheet(SheetStyle::FORGETPWD_VALIDATION_LINEEDIT);
editValidate->setTextMargins(this->screenWidth()*0.02, 0, this->screenWidth()*0.02, 0);
QVBoxLayout* vbInfoLayout = new QVBoxLayout;
vbInfoLayout->addWidget(lblMsgHint);
vbInfoLayout->addWidget(editValidate);
vbInfoLayout->setAlignment(Qt::AlignCenter);
vbInfoLayout->setSpacing(0);
vbInfoLayout->setMargin(0);
btnNextStep = new QPushButton(tr("下一步"), this);
btnNextStep->setFixedHeight(this->screenHeight()*0.074);
btnNextStep->setStyleSheet(SheetStyle::QPUSHBUTTON);
connect(btnNextStep, SIGNAL(clicked()), this, SLOT(on_btnNextStep_clicked()));
QVBoxLayout* vbLayout = new QVBoxLayout;
vbLayout->addLayout(vbInfoLayout);
vbLayout->addSpacing(this->screenHeight()*0.03);
vbLayout->addWidget(btnNextStep);
vbLayout->setAlignment(Qt::AlignTop);
vbLayout->addStretch(0);
vbLayout->addSpacing(0);
vbLayout->setContentsMargins(this->screenWidth()*0.054,this->screenHeight()*0.026,this->screenWidth()*0.054,0);
this->setBodyPartLayout(vbLayout);
}
示例6: pathx
ConnectionSslTab::ConnectionSslTab(ConnectionSettings *settings) :
_settings(settings)
{
_sslPemFilePath = new QLineEdit(QtUtils::toQString(_settings->sslInfo()._sslPEMKeyFile));
/*
// Commented because of this:
// https://github.com/paralect/robomongo/issues/391
#ifdef Q_OS_WIN
QRegExp pathx("([a-zA-Z]:)?([\\\\/][a-zA-Z0-9_.-]+)+[\\\\/]?");
#else
QRegExp pathx("^\\/?([\\d\\w\\.]+)(/([\\d\\w\\.]+))*\\/?$");
#endif // Q_OS_WIN
_sslPemFilePath->setValidator(new QRegExpValidator(pathx, this));
*/
_sslSupport = new QCheckBox("Use SSL protocol");
_sslSupport->setStyleSheet("margin-bottom: 7px");
_sslSupport->setChecked(_settings->sslInfo()._sslSupport);
_selectPemFileButton = new QPushButton("...");
_selectPemFileButton->setFixedSize(20, 20);
VERIFY(connect(_selectPemFileButton, SIGNAL(clicked()), this, SLOT(setSslPEMKeyFile())));
_sslPemLabel = new QLabel("SSL Certificate:");
_sslPemDescriptionLabel = new QLabel(
"<nobr>SSL Certificate and SSL Private Key combined into one file (*.pem)");
_sslPemDescriptionLabel->setWordWrap(true);
_sslPemDescriptionLabel->setAlignment(Qt::AlignTop);
_sslPemDescriptionLabel->setContentsMargins(0, -2, 0, 0);
_sslPemDescriptionLabel->setMinimumSize(_sslPemDescriptionLabel->sizeHint());
QLabel *sslNoteLabel = new QLabel(
"<b>Note:</b> Support for Certificate Authority (CA) file and "
"encrypted SSL Private Keys are planned for future releases.");
sslNoteLabel->setWordWrap(true);
sslNoteLabel->setAlignment(Qt::AlignTop);
sslNoteLabel->setContentsMargins(0, 20, 0, 0);
QGridLayout *_authLayout = new QGridLayout;
_authLayout->setAlignment(Qt::AlignTop);
_authLayout->addWidget(_sslSupport, 0, 0, 1, 3);
_authLayout->addWidget(_sslPemLabel, 1, 0);
_authLayout->addWidget(_sslPemFilePath, 1, 1, 1, 1);
_authLayout->addWidget(_selectPemFileButton, 1, 2, 1, 1);
_authLayout->addWidget(_sslPemDescriptionLabel, 2, 1, 1, 2);
_authLayout->addWidget(sslNoteLabel, 3, 0, 1, 4);
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addLayout(_authLayout);
setLayout(mainLayout);
sslSupportStateChange(_sslSupport->checkState());
VERIFY(connect(_sslSupport, SIGNAL(stateChanged(int)), this, SLOT(sslSupportStateChange(int))));
}
示例7: QWidget
Change::Change(QWidget *parent) :
QWidget(parent),
ui(new Ui::Change)
{
pathToRes = new QString("/home/midv/Projects/TrajectoryBuilder/Trajectory/resourses/");
ui->setupUi(this);
QHBoxLayout *generalLay = new QHBoxLayout(this);
generalLay->setContentsMargins(0,0,0,0);
QLabel *label = new QLabel();
label->setFixedSize(this->size());
label->setContentsMargins(0,0,0,0);
label->setStyleSheet("QLabel{border:4px solid #00aa00; border-radius:10px}");
generalLay->addWidget(label);
QHBoxLayout *lay = new QHBoxLayout();
label->setLayout(lay);
lay->setAlignment(Qt::AlignCenter);
lay->setSpacing(0);
lay->setContentsMargins(5,0,0,0);
QtSvgButton *button1 = new QtSvgButton();
button1->setLockalSkin(*pathToRes,"Line");
connect(button1,SIGNAL(clicked()),SLOT(pressButton1()));
button1->setFixedSize(110,110);
lay->addWidget(button1);
QtSvgButton *button2 = new QtSvgButton();
button2->setLockalSkin(*pathToRes,"Aссel");
connect(button2,SIGNAL(clicked()),SLOT(pressButton2()));
button2->setFixedSize(110,110);
lay->addWidget(button2);
QtSvgButton *button3 = new QtSvgButton();
button3->setLockalSkin(*pathToRes,"ArcV");
connect(button3,SIGNAL(clicked()),SLOT(pressButton3()));
button3->setFixedSize(110,110);
lay->addWidget(button3);
QtSvgButton *button4 = new QtSvgButton();
button4->setLockalSkin(*pathToRes,"ArcH");
connect(button4,SIGNAL(clicked()),SLOT(pressButton4()));
button4->setFixedSize(110,110);
lay->addWidget(button4);
QtSvgButton *button5 = new QtSvgButton();
button5->setLockalSkin(*pathToRes,"ZmeyV");
connect(button5,SIGNAL(clicked()),SLOT(pressButton5()));
button5->setFixedSize(110,110);
lay->addWidget(button5);
QtSvgButton *button6 = new QtSvgButton();
button6->setLockalSkin(*pathToRes,"ZmeyH");
connect(button6,SIGNAL(clicked()),SLOT(pressButton6()));
button6->setFixedSize(110,110);
lay->addWidget(button6);
QtSvgButton *button7 = new QtSvgButton();
button7->setLockalSkin(*pathToRes,"Remove");
connect(button7,SIGNAL(clicked()),SLOT(pressButton7()));
button7->setFixedSize(110,110);
lay->addWidget(button7);
}
示例8: 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 );
}
示例9: QWidget
QgsWelcomePage::QgsWelcomePage( bool skipVersionCheck, QWidget *parent )
: QWidget( parent )
{
QgsSettings settings;
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->setMargin( 0 );
mainLayout->setContentsMargins( 0, 0, 0, 0 );
setLayout( mainLayout );
QHBoxLayout *layout = new QHBoxLayout();
layout->setMargin( 0 );
mainLayout->addLayout( layout );
QWidget *recentProjectsContainer = new QWidget;
recentProjectsContainer->setLayout( new QVBoxLayout );
recentProjectsContainer->layout()->setContentsMargins( 0, 0, 0, 0 );
recentProjectsContainer->layout()->setMargin( 0 );
int titleSize = QApplication::fontMetrics().height() * 1.4;
QLabel *recentProjectsTitle = new QLabel( QStringLiteral( "<div style='font-size:%1px;font-weight:bold'>%2</div>" ).arg( titleSize ).arg( tr( "Recent Projects" ) ) );
recentProjectsTitle->setContentsMargins( 10, 3, 0, 0 );
recentProjectsContainer->layout()->addWidget( recentProjectsTitle );
mRecentProjectsListView = new QListView();
mRecentProjectsListView->setResizeMode( QListView::Adjust );
mRecentProjectsListView->setContextMenuPolicy( Qt::CustomContextMenu );
connect( mRecentProjectsListView, &QListView::customContextMenuRequested, this, &QgsWelcomePage::showContextMenuForProjects );
mModel = new QgsWelcomePageItemsModel( mRecentProjectsListView );
mRecentProjectsListView->setModel( mModel );
mRecentProjectsListView->setItemDelegate( new QgsWelcomePageItemDelegate( mRecentProjectsListView ) );
recentProjectsContainer->layout()->addWidget( mRecentProjectsListView );
layout->addWidget( recentProjectsContainer );
mVersionInformation = new QLabel;
mainLayout->addWidget( mVersionInformation );
mVersionInformation->setVisible( false );
mVersionInfo = new QgsVersionInfo();
if ( !QgsApplication::isRunningFromBuildDir() && settings.value( QStringLiteral( "qgis/checkVersion" ), true ).toBool() && !skipVersionCheck )
{
connect( mVersionInfo, &QgsVersionInfo::versionInfoAvailable, this, &QgsWelcomePage::versionInfoReceived );
mVersionInfo->checkVersion();
}
connect( mRecentProjectsListView, &QAbstractItemView::activated, this, &QgsWelcomePage::itemActivated );
}
示例10: context
//
// Version page
//
VersionPage::VersionPage(Context *context) : context(context)
{
QLabel *text;
text=new QLabel(this);
text->setContentsMargins(0,0,0,0);
text->setText(GcCrashDialog::versionHTML());
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->setSpacing(0);
mainLayout->setContentsMargins(0,0,0,0);
mainLayout->addWidget(text);
setLayout(mainLayout);
}
示例11: main
//
// Version page
//
VersionPage::VersionPage(MainWindow *main, QDir home) : main(main), home(home)
{
QLabel *text;
text=new QLabel(this);
text->setContentsMargins(0,0,0,0);
text->setText(GcCrashDialog::versionHTML());
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->setSpacing(0);
mainLayout->setContentsMargins(0,0,0,0);
mainLayout->addWidget(text);
setLayout(mainLayout);
}
示例12: QLabel
QHBoxLayout *FAttentionSettingsWidget::buildHBox(QString labeltext, QWidget *widget)
{
QHBoxLayout *hbox = new QHBoxLayout;
QLabel *label = new QLabel(labeltext, this);
label->setObjectName("settingslabel");
label->setContentsMargins(0, 0, 0, 0);
hbox->addWidget(label);
hbox->addStretch();
if(widget) {
hbox->addWidget(widget);
}
return hbox;
}
示例13: appendLine
void LogListWidget::appendLine(const QString &line)
{
QListWidgetItem *item = new QListWidgetItem;
// We need to use QLabel here to support rich text
QLabel *lbl = new QLabel(line);
lbl->setContentsMargins(4, 2, 4, 2);
item->setSizeHint(lbl->sizeHint());
insertItem(0, item);
setItemWidget(item, lbl);
const int nbLines = count();
// Limit log size
if (nbLines > m_maxLines)
delete takeItem(nbLines - 1);
}
示例14: setParent
FilesystemWidget::FilesystemWidget(QWidget *parent)
{
setParent(parent);
// Create the toolbar
QToolBar *fsToolbar = new QToolBar();
fsToolbar->setMovable(false);
goUpAction = new QAction(IconFactory::fromTheme("go-up"), tr("Go up"), this);
connect(goUpAction, SIGNAL(triggered()), this, SLOT(goUp()));
fsToolbar->addAction(goUpAction);
goHomeAction = new QAction(IconFactory::fromTheme("go-home"), tr("Go to the home folder"), this);
connect(goHomeAction, SIGNAL(triggered()), this, SLOT(goHome()));
fsToolbar->addAction(goHomeAction);
// TODO: use placeholderText in Qt 4.7.
filterEdit = new QLineEdit();
QLabel* filterLabel = new QLabel(tr("Filter:"));
filterLabel->setContentsMargins(5, 0, 5, 0);
fsToolbar->addSeparator();
fsToolbar->addWidget(filterLabel);
fsToolbar->addWidget(filterEdit);
connect(filterEdit, SIGNAL(textChanged(QString)), this, SLOT(setNameFilter(QString)));
// Create the filesystem view
fsWidgetModel = new QFileSystemModel();
fsWidgetModel->setNameFilterDisables(false);
fsWidgetModel->setFilter(QDir::AllDirs|QDir::Files|QDir::NoDotAndDotDot);
fsListView = new QListView();
fsListView->setSelectionMode(QAbstractItemView::ExtendedSelection);
fsListView->setDragEnabled(true);
fsListView->setModel(fsWidgetModel);
// We shall use this to filter available file extensions from Phonon
//fsWidgetModel->setFilter(getPhononExtensions());
connect(fsWidgetModel, SIGNAL(rootPathChanged(QString)), this, SLOT(pathChanged()));
connect(fsListView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(doubleClickAt(QModelIndex)));
// Create a new horizontal box
QVBoxLayout *vlayout = new QVBoxLayout();
vlayout->addWidget(fsToolbar);
vlayout->addWidget(fsListView);
goHome();
this->setLayout(vlayout);
}
示例15: QLabel
KSaneDeviceDialog::KSaneDeviceDialog(QWidget *parent)
: KDialog(parent)
{
setButtons(KDialog::User1 | KDialog::Ok | KDialog::Cancel);
setButtonText(User1, i18n("Reload devices list"));
m_btnGroup = new QButtonGroup(this);
m_btnBox = new QGroupBox;
QVBoxLayout *layout = new QVBoxLayout;
m_btnContainer = new QWidget;
m_btnLayout = new QVBoxLayout(m_btnContainer);
QScrollArea *area = new QScrollArea;
m_btnBox->setLayout(layout);
QLabel *explanation =
new QLabel(i18n("<html>The SANE (Scanner Access Now Easy) system could not find any device.<br>"
"Check that the scanner is plugged in and turned on<br>"
"or check your systems scanner setup.<br>"
"For details about SANE see the "
"<a href='http://www.sane-project.org/'>SANE homepage</a>.</html>"));
explanation->setOpenExternalLinks(true);
int l,t,r,b;
layout->getContentsMargins(&l, &t, &r, &b);
explanation->setContentsMargins(l, t, r, b);
layout->addWidget(explanation);
m_btnBox->adjustSize(); // make sure to see the complete explanation text
layout->addWidget(area);
layout->setContentsMargins(0,0,0,0);
area->setWidgetResizable(true);
area->setFrameShape(QFrame::NoFrame);
area->setWidget(m_btnContainer);
setMainWidget(m_btnBox);
setMinimumHeight(200);
m_findDevThread = FindSaneDevicesThread::getInstance();
connect(m_findDevThread, SIGNAL(finished()), this, SLOT(updateDevicesList()));
connect(this, SIGNAL(user1Clicked()), this, SLOT(reloadDevicesList()));
reloadDevicesList();
}