本文整理汇总了C++中QLabel::setLineWidth方法的典型用法代码示例。如果您正苦于以下问题:C++ QLabel::setLineWidth方法的具体用法?C++ QLabel::setLineWidth怎么用?C++ QLabel::setLineWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QLabel
的用法示例。
在下文中一共展示了QLabel::setLineWidth方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: main
int main(int argc, char** argv) {
QApplication app(argc, argv);
QWidget wgt;
wgt.setWindowTitle("LineEdit");
QLabel* plblDisplay = new QLabel;
plblDisplay->setFrameStyle(QFrame::Box | QFrame::Raised);
plblDisplay->setLineWidth(2);
plblDisplay->setFixedHeight(50);
QLabel* plblText = new QLabel("&Text");
QLineEdit* ptxt = new QLineEdit;
plblText->setBuddy(ptxt);
QObject::connect(ptxt, SIGNAL(textChanged(const QString&)), plblDisplay, SLOT(setText(const QString&)));
QLabel* plblPassword = new QLabel("&Password");
QLineEdit* ptxtPassword = new QLineEdit;
plblPassword->setBuddy(ptxtPassword);
ptxtPassword->setEchoMode(QLineEdit::Password);
QObject::connect(ptxtPassword, SIGNAL(textChanged(const QString&)), plblDisplay, SLOT(setText(const QString&)));
QVBoxLayout* pvbxLayout = new QVBoxLayout;
pvbxLayout->addWidget(plblDisplay);
pvbxLayout->addWidget(plblText);
pvbxLayout->addWidget(ptxt);
pvbxLayout->addWidget(plblPassword);
pvbxLayout->addWidget(ptxtPassword);
wgt.setLayout(pvbxLayout);
wgt.show();
return app.exec();
}
示例3: createAndAddWidget
/* Overloading the AbstractController one, because we don't manage the
Spacing items in the same ways */
void DroppingController::createAndAddWidget( QBoxLayout *newControlLayout,
int i_index,
buttonType_e i_type,
int i_option )
{
/* Special case for SPACERS, who aren't QWidgets */
if( i_type == WIDGET_SPACER || i_type == WIDGET_SPACER_EXTEND )
{
QLabel *label = new QLabel( this );
label->setPixmap( ImageHelper::loadSvgToPixmap( ":/toolbar/space.svg", height(), height() ) );
if( i_type == WIDGET_SPACER_EXTEND )
{
label->setSizePolicy( QSizePolicy::MinimumExpanding,
QSizePolicy::Preferred );
/* Create a box around it */
label->setFrameStyle( QFrame::Panel | QFrame::Sunken );
label->setLineWidth ( 1 );
label->setAlignment( Qt::AlignCenter );
}
else
label->setSizePolicy( QSizePolicy::Fixed,
QSizePolicy::Preferred );
/* Install event Filter for drag'n drop */
label->installEventFilter( this );
newControlLayout->insertWidget( i_index, label );
}
/* Normal Widgets */
else
{
QWidget *widg = createWidget( i_type, i_option );
if( !widg ) return;
/* Install the Event Filter in order to catch the drag */
widg->setParent( this );
widg->installEventFilter( this );
/* We are in a complex widget, we need to stop events on children too */
if( i_type >= TIME_LABEL && i_type < SPECIAL_MAX )
{
QList<QObject *>children = widg->children();
QObject *child;
foreach( child, children )
{
QWidget *childWidg;
if( ( childWidg = qobject_cast<QWidget *>( child ) ) )
{
child->installEventFilter( this );
childWidg->setEnabled( true );
}
}
/* Decorating the frames when possible */
QFrame *frame;
if( (i_type >= MENU_BUTTONS || i_type == TIME_LABEL) /* Don't bother to check for volume */
&& ( frame = qobject_cast<QFrame *>( widg ) ) != NULL )
{
frame->setFrameStyle( QFrame::Panel | QFrame::Raised );
frame->setLineWidth ( 1 );
}
}
示例4: ShowConfig
void Config::ShowConfig()
{
// create dialog
QDialog *window = new QDialog;
// Config Logo header
QPixmap *pixLogo = new QPixmap;
// load logo image from file
pixLogo->load(":/images/cst_config_logo.png");
// show logo file on label
QLabel *labelConfigLogo = new QLabel;
labelConfigLogo->setPixmap(*pixLogo);
labelConfigLogo->setFrameStyle(QFrame::Panel | QFrame::Sunken);
labelConfigLogo->setLineWidth(2);
tabWidget = new QTabWidget;
recordTab = new RecordingTab;
userTab = new UserTab;
generalTab = new GeneralTab;
tabWidget->addTab(recordTab, tr("&Recording"));
tabWidget->addTab(userTab, tr("&User"));
tabWidget->addTab(generalTab, tr("&General"));
// Buttons
QHBoxLayout *hButtonBox = new QHBoxLayout;
hButtonBox->addStretch(1);
// create ok button
QPushButton *okButton = new QPushButton(tr("&Ok"));
// set ok button to default and accept
connect(okButton, SIGNAL(clicked()), this, SLOT(SaveSettings()));
connect(this, SIGNAL(SavedSettings()), window, SLOT(accept()));
// create cancel button
QPushButton *cancelButton = new QPushButton(tr("&Cancel"));
connect(cancelButton, SIGNAL(clicked()), window, SLOT(reject()));
cancelButton->setDefault(false);
hButtonBox->addWidget(okButton);
hButtonBox->addWidget(cancelButton);
// everything
QVBoxLayout *vBox = new QVBoxLayout(window);
vBox->addWidget(labelConfigLogo);
vBox->addWidget(tabWidget); // configuration tabs
vBox->addLayout(hButtonBox); // ok and cancel buttons
window->setLayout(vBox);
okButton->setDefault(true);
window->setGeometry(200,200,400,50);
window->setWindowTitle("VoiceLog1 Configuration");
window->setWindowIcon(QIcon(QPixmap(":/images/icons/appIcon.png")));
// create our settings object
QSettings voiceLogSettings;
// get the recording settings
recordTab->editRecPath->setText(voiceLogSettings.value("config/recording/Path").toString()); // the path of the recordings - usually app directory
recordTab->editRecName->setText(voiceLogSettings.value("config/recording/Name").toString()); // record file name
recordTab->spinThreshTimer->setValue(voiceLogSettings.value("config/recording/Timer").toInt()); // under threshold timer
// get the user settings
userTab->editCompany->setText(voiceLogSettings.value("config/user/Company").toString()); // company name
userTab->editDept->setText(voiceLogSettings.value("config/user/Department").toString()); // department
userTab->editUser->setText(voiceLogSettings.value("config/user/Username").toString()); // username
// get general settings
generalTab->checkStart->setCheckState(Qt::CheckState(voiceLogSettings.value("config/general/AutoStart").toInt())); // auto start
generalTab->checkConfig->setCheckState(Qt::CheckState(voiceLogSettings.value("config/general/AllowConfig").toInt())); // allow access to configuration
generalTab->checkDeactivate->setCheckState(Qt::CheckState(voiceLogSettings.value("config/general/AllowDeactivate").toInt())); // allow access to deactivation
generalTab->checkPlayback->setCheckState(Qt::CheckState(voiceLogSettings.value("config/general/AllowPlayback").toInt())); // allow playback of recordings
generalTab->checkHidden->setCheckState(Qt::CheckState(voiceLogSettings.value("config/general/GoStealth").toInt())); // go into stealth mode - set process id different and no gui
generalTab->checkComments->setCheckState(Qt::CheckState(voiceLogSettings.value("config/general/Comments").toInt())); // go into stealth mode - set process id different and no gui
window->exec();
}
示例5: QPushButton
MainWidget::MainWidget(QWidget* parent)
:QWidget(parent),
mp_glwidget(0),
mp_box(0),
mp_timer(0),
m_tick_timer(),
mp_fps_timer(0),
m_current_fps(0),
m_fps_counter(0)
{
// build main window components and layout
{
// buttons setup
{
mp_buttons[0] = new QPushButton(tr("Forward (W)" ));
mp_buttons[1] = new QPushButton(tr("Left (A)" ));
mp_buttons[2] = new QPushButton(tr("Backward (S)"));
mp_buttons[3] = new QPushButton(tr("Right (D)" ));
m_button_keys[0] = Qt::Key_W;
m_button_keys[1] = Qt::Key_A;
m_button_keys[2] = Qt::Key_S;
m_button_keys[3] = Qt::Key_D;
for (int i=0; i<4; i++)
mp_buttons[i]->setFocusPolicy(Qt::NoFocus);
}
// create main components
mp_glwidget = new GLDemoWidget;
mp_box = new QGroupBox;
QBoxLayout* box_l = new QHBoxLayout(mp_box);
QGridLayout* layout = new QGridLayout;
QLabel* label = new QLabel
(QString(tr("Shaolin Sheep (c) 2006 Sylvain Bernier\n"))+
QString(tr("< [email protected] >\n"))+
QString(tr("Version %1\n")).arg(SS_VERSION)+
QString(tr("This is free software, see the file COPYING.\n")));
{
label->setAlignment(Qt::AlignTop);
label->setFrameStyle(QFrame::Panel | QFrame::Sunken);
label->setLineWidth(2);
label->setMargin(2);
}
QLabel* label2 = new QLabel
(tr(" Click on the scene to (des)activate camera control. Press [SpaceBar] to jump. Protect the sheep! (or try right clicking) "));
{
label2->setAlignment(Qt::AlignTop | Qt::AlignCenter);
label2->setFrameStyle(QFrame::Box | QFrame::Sunken);
label2->setLineWidth(1);
label->setMargin(1);
}
// create main layout
layout->addWidget(mp_box, 0, 0, 1, 4);
layout->addWidget(mp_buttons[0], 1, 1 );
layout->addWidget(mp_buttons[1], 2, 0 );
layout->addWidget(mp_buttons[2], 2, 1 );
layout->addWidget(mp_buttons[3], 2, 2 );
layout->addWidget(label, 1, 3, 2, 1);
layout->addWidget(label2, 3, 0, 1, 4);
layout->setRowStretch(0, 1);
layout->setRowMinimumHeight(0, 200);
setLayout(layout);
mp_box->setTitle(tr("Welcome! "));
box_l->addWidget(mp_glwidget);
resize(625, 550);
}
// initialize main application timer
mp_timer = new QTimer;
connect(mp_timer, SIGNAL(timeout()), this, SLOT(tick()));
mp_timer->start(TICK_INTERVAL);
m_tick_timer.start();
// initialize 'frame per second' timer
mp_fps_timer = new QTimer;
connect(mp_fps_timer, SIGNAL(timeout()), this, SLOT(fps_tick()));
mp_fps_timer->start(1000);
}
示例6: QToolButton
CProperties::CProperties( QWidget* parent, const char* name, HODBCINSTPROPERTY hTheFirstProperty )
: QMainWindow( parent, name, 0 )
{
HODBCINSTPROPERTY hProperty;
int nProperty;
pMainWidget = new QWidget( this );
setCentralWidget( pMainWidget );
pTopLayout = new QVBoxLayout( pMainWidget );
// SETUP TOOLBAR
toolbarMain = new QToolBar( this );
addToolBar( toolbarMain, tr( "ToolBar" ), Top, FALSE );
new QToolButton( QPixmap( checkOk_xpm ), QString(tr("Save and Exit")), QString(""), this, SLOT(pbOk_Clicked()), toolbarMain );
new QToolButton( QPixmap( checkCancel_xpm ), QString(tr("Cancel any changes and Exit")), QString(""), this, SLOT(pbCancel_Clicked()), toolbarMain );
QWhatsThis::whatsThisButton ( toolbarMain );
/* PROPERTIES */
hFirstProperty = hTheFirstProperty;
for ( nProperties = 0, hProperty = hFirstProperty; hProperty != NULL; hProperty = hProperty->pNext )
{
nProperties++;
}
pGridLayout = new QGridLayout( nProperties, 2, 2 );
pTopLayout->addLayout( pGridLayout );
pGridLayout->setColStretch ( 0, 0 );
pGridLayout->setColStretch ( 1, 1 );
for ( nProperty = 0, hProperty = hFirstProperty; hProperty != NULL; nProperty++, hProperty = hProperty->pNext )
{
QLabel *pLabel = new QLabel( pMainWidget );
// 1ST COLUMN IS ALWAYS A LABEL CONTAINING THE PROPERTY NAME
if ( hProperty->nPromptType != ODBCINST_PROMPTTYPE_HIDDEN )
{
if ( hProperty->pszHelp )
QWhatsThis::add( pLabel, hProperty->pszHelp );
pLabel->setLineWidth( 1 );
pLabel->setText( hProperty->szName );
pLabel->setMinimumSize( pLabel->sizeHint() );
pLabel->setFixedHeight( pLabel->sizeHint().height() );
pGridLayout->addWidget( pLabel, nProperty, 0 );
}
// 2ND COLUMN IS WHERE THE USER ENTERS DATA SO CREATE A WIDGET THAT IS MEANINGFULL
switch ( hProperty->nPromptType )
{
case ODBCINST_PROMPTTYPE_LABEL:
{
QLabel *pLabel2 = new QLabel( pMainWidget );
if ( hProperty->pszHelp )
QWhatsThis::add( pLabel2, hProperty->pszHelp );
pLabel2->setFrameStyle( QFrame::Box | QFrame::Sunken );
pLabel2->setLineWidth( 1 );
pLabel2->setText( hProperty->szValue );
pLabel2->setMinimumSize( pLabel2->sizeHint() );
pLabel2->setFixedHeight( pLabel2->sizeHint().height() );
pGridLayout->addWidget( pLabel2, nProperty, 1 );
hProperty->pWidget = pLabel2;
if ( hProperty->pszHelp ) QToolTip::add( pLabel2, hProperty->pszHelp );
}
break;
case ODBCINST_PROMPTTYPE_LISTBOX:
{
QComboBox *pComboBox = new QComboBox( pMainWidget );
if ( hProperty->pszHelp )
QWhatsThis::add( pComboBox, hProperty->pszHelp );
pComboBox->insertStrList( (const char **)hProperty->aPromptData );
pComboBox->setMinimumSize( pComboBox->sizeHint() );
pComboBox->setFixedHeight( pComboBox->sizeHint().height() );
pGridLayout->addWidget( pComboBox, nProperty, 1 );
hProperty->pWidget = pComboBox;
if ( hProperty->pszHelp ) QToolTip::add( pComboBox, hProperty->pszHelp );
setCurrentItem( pComboBox, hProperty->szValue );
}
break;
case ODBCINST_PROMPTTYPE_COMBOBOX:
{
QComboBox *pComboBox = new QComboBox( true, pMainWidget );
if ( hProperty->pszHelp )
QWhatsThis::add( pComboBox, hProperty->pszHelp );
pComboBox->insertStrList( (const char **)hProperty->aPromptData );
pComboBox->setEditText( hProperty->szValue );
pComboBox->setMinimumSize( pComboBox->sizeHint() );
pComboBox->setFixedHeight( pComboBox->sizeHint().height() );
pGridLayout->addWidget( pComboBox, nProperty, 1 );
hProperty->pWidget = pComboBox;
if ( hProperty->pszHelp ) QToolTip::add( pComboBox, hProperty->pszHelp );
}
break;
case ODBCINST_PROMPTTYPE_FILENAME:
{
CFileSelector *pFileSelector = new CFileSelector( pMainWidget );
if ( hProperty->pszHelp )
QWhatsThis::add( pFileSelector, hProperty->pszHelp );
pFileSelector->pLineEdit->setText( hProperty->szValue );
pGridLayout->addWidget( pFileSelector, nProperty, 1 );
hProperty->pWidget = pFileSelector;
if ( hProperty->pszHelp ) QToolTip::add( pFileSelector, hProperty->pszHelp );
//.........这里部分代码省略.........
示例7: main
int main (int argc, char** argv)
{
QApplication app(argc, argv);
QWidget wgt;
QStringList list;
list << "1" << "2" << "3" <<"4";
QTableWidget mytable(4, 5);
QTableWidgetItem* pw = NULL;
mytable.setHorizontalHeaderLabels(list);
mytable.setVerticalHeaderLabels(list);
QBrush br(Qt::BackgroundColorRole, Qt::NoBrush);
for(int i(0);i < 4; i++)
for(int j(0); j < 5; j++){
pw = new QTableWidgetItem(QString("%10, %11").arg(i).arg(j));
pw->setBackground(br);
//pw->setBackgroundColor(QColor::black());
//pw->setBackgroundColor(&c);
mytable.setItem(i, j, pw);
}
QComboBox* box = new QComboBox;
box->addItems(list);
QString str ("111");
QTabWidget tab;
// foreach(QString str, list){
// tab.addTab(new QLabel(str, &tab), str);
// }
QLabel* la = new QLabel(str, &tab);
tab.addTab(la, QString("1"));
tab.addTab(new QLineEdit, str);
QToolBox * gg = new QToolBox;
gg->addItem(new QLineEdit, QString("222"));
QLabel* plblDisplay = new QLabel;
plblDisplay->setFrameStyle(QFrame::Box | QFrame::Raised);
plblDisplay->setLineWidth(5);
plblDisplay->setFixedHeight(50);
QLabel* plblText = new QLabel("&Text:");
QLineEdit* text = new QLineEdit;
text->setInputMask("0-(000)-000-00-00");
QLineEdit* text3 = new QLineEdit;
text3->setInputMask("0-(000)-000-00-00");
tab.addTab(text3, QString("0-(000)-000-00-00"));
QWidget::connect(tab.widget(0), SIGNAL(objectNameChanged(QString)),tab.widget(2), SLOT(setEnabled(bool)));
QTextEdit* text2 = new QTextEdit;
text2->setHtml("<html><div><center><h3>I wrote the HTML</h3></center></div></html>");
MyHighlighter* pHighlighter = new MyHighlighter(text2->document());
QLineEdit* ptxt = new QLineEdit;
plblText->setBuddy(ptxt);
QObject::connect(ptxt, SIGNAL(textChanged(const QString&)),
plblDisplay, SLOT(setText(const QString&))
);
QObject::connect(text, SIGNAL(textChanged(const QString&)),
plblDisplay, SLOT(setText(const QString&))
);
QObject::connect(text2, SIGNAL(windowTitleChanged(QString)),
plblDisplay, SLOT(setText(const QString&))
);
QLabel* plblPassword = new QLabel("&Password:");
QLineEdit* ptxtPassword = new QLineEdit;
plblPassword->setBuddy(ptxtPassword);
ptxtPassword->setEchoMode(QLineEdit::Password);
ptxtPassword->setValidator(new QIntValidator);
QObject::connect(ptxtPassword, SIGNAL(textChanged(const QString&)),
plblDisplay, SLOT(setText(const QString&))
);
//Layout setup
QVBoxLayout* pvbxLayout = new QVBoxLayout;
pvbxLayout->addWidget(plblDisplay);
pvbxLayout->addWidget(plblText);
pvbxLayout->addWidget(ptxt);
pvbxLayout->addWidget(plblPassword);
pvbxLayout->addWidget(ptxtPassword);
pvbxLayout->addWidget(text);
pvbxLayout->addWidget(text2);
pvbxLayout->addWidget(box);
pvbxLayout->addWidget(&tab);
pvbxLayout->addWidget(&mytable);
//.........这里部分代码省略.........