本文整理汇总了C++中QLabel类的典型用法代码示例。如果您正苦于以下问题:C++ QLabel类的具体用法?C++ QLabel怎么用?C++ QLabel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QLabel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QDialog
SpiceDialog::SpiceDialog(SpiceFile *c, Schematic *d)
: QDialog(d, 0, TRUE, Qt::WDestructiveClose)
{
resize(400, 250);
setCaption(tr("Edit SPICE Component Properties"));
Comp = c;
Doc = d;
all = new Q3VBoxLayout(this); // to provide neccessary size
QWidget *myParent = this;
Expr.setPattern("[^\"=]+"); // valid expression for property 'edit' etc
Validator = new QRegExpValidator(Expr, this);
Expr.setPattern("[\\w_]+"); // valid expression for property 'NameEdit' etc
ValRestrict = new QRegExpValidator(Expr, this);
// ...........................................................
Q3GridLayout *topGrid = new Q3GridLayout(0, 4,3,3,3);
all->addLayout(topGrid);
topGrid->addWidget(new QLabel(tr("Name:"), myParent), 0,0);
CompNameEdit = new QLineEdit(myParent);
CompNameEdit->setValidator(ValRestrict);
topGrid->addWidget(CompNameEdit, 0,1);
connect(CompNameEdit, SIGNAL(returnPressed()), SLOT(slotButtOK()));
topGrid->addWidget(new QLabel(tr("File:"), myParent), 1,0);
FileEdit = new QLineEdit(myParent);
FileEdit->setValidator(ValRestrict);
topGrid->addWidget(FileEdit, 1,1);
connect(FileEdit, SIGNAL(returnPressed()), SLOT(slotButtOK()));
ButtBrowse = new QPushButton(tr("Browse"), myParent);
topGrid->addWidget(ButtBrowse, 1,2);
connect(ButtBrowse, SIGNAL(clicked()), SLOT(slotButtBrowse()));
ButtEdit = new QPushButton(tr("Edit"), myParent);
topGrid->addWidget(ButtEdit, 2,2);
connect(ButtEdit, SIGNAL(clicked()), SLOT(slotButtEdit()));
FileCheck = new QCheckBox(tr("show file name in schematic"), myParent);
topGrid->addWidget(FileCheck, 2,1);
SimCheck = new QCheckBox(tr("include SPICE simulations"), myParent);
topGrid->addWidget(SimCheck, 3,1);
Q3HBox *h1 = new Q3HBox(myParent);
h1->setSpacing(5);
PrepCombo = new QComboBox(h1);
PrepCombo->insertItem("none");
PrepCombo->insertItem("ps2sp");
PrepCombo->insertItem("spicepp");
PrepCombo->insertItem("spiceprm");
QLabel * PrepLabel = new QLabel(tr("preprocessor"), h1);
PrepLabel->setMargin(5);
topGrid->addWidget(h1, 4,1);
connect(PrepCombo, SIGNAL(activated(int)), SLOT(slotPrepChanged(int)));
// ...........................................................
Q3GridLayout *midGrid = new Q3GridLayout(0, 2,3,5,5);
all->addLayout(midGrid);
midGrid->addWidget(new QLabel(tr("SPICE net nodes:"), myParent), 0,0);
NodesList = new Q3ListBox(myParent);
midGrid->addWidget(NodesList, 1,0);
connect(NodesList, SIGNAL(doubleClicked(Q3ListBoxItem*)),
SLOT(slotAddPort(Q3ListBoxItem*)));
Q3VBox *v0 = new Q3VBox(myParent);
v0->setSpacing(5);
midGrid->addWidget(v0, 1,1);
ButtAdd = new QPushButton(tr("Add >>"), v0);
connect(ButtAdd, SIGNAL(clicked()), SLOT(slotButtAdd()));
ButtRemove = new QPushButton(tr("<< Remove"), v0);
connect(ButtRemove, SIGNAL(clicked()), SLOT(slotButtRemove()));
v0->setStretchFactor(new QWidget(v0), 5); // stretchable placeholder
midGrid->addWidget(new QLabel(tr("Component ports:"), myParent), 0,2);
PortsList = new Q3ListBox(myParent);
midGrid->addWidget(PortsList, 1,2);
connect(PortsList, SIGNAL(doubleClicked(Q3ListBoxItem*)),
SLOT(slotRemovePort(Q3ListBoxItem*)));
// ...........................................................
Q3HBox *h0 = new Q3HBox(this);
h0->setSpacing(5);
all->addWidget(h0);
connect(new QPushButton(tr("OK"),h0), SIGNAL(clicked()),
SLOT(slotButtOK()));
connect(new QPushButton(tr("Apply"),h0), SIGNAL(clicked()),
SLOT(slotButtApply()));
connect(new QPushButton(tr("Cancel"),h0), SIGNAL(clicked()),
SLOT(slotButtCancel()));
// ------------------------------------------------------------
CompNameEdit->setText(Comp->Name);
changed = false;
//.........这里部分代码省略.........
示例2: on_statsTree_currentItemChanged
void StatsView::on_statsTree_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous)
{
if (current == 0)
return;
std::string data = "";
if (current->childCount() == 0) {
DataContainerTreeItem *treeData = (DataContainerTreeItem *)current;
data = treeData->getData();
}
QTreeWidget *statsTree = this->findChild<QTreeWidget *>("statsTree");
QLabel *modName = this->findChild<QLabel *>("modName");
QTableWidget *modTable = this->findChild<QTableWidget *>("modTable");
modTable->blockSignals(true);
StatsContainer *itemStats = GenStatsReader::getContainer(allItemStats, data.c_str());
if (itemStats != 0) {
modName->setText(itemStats->getArg(0).c_str());
std::map<std::string, std::string> baseData = itemStats->getBaseDataMap();
if (itemStats->getUsing() != 0) {
std::map<std::string, std::string> parentData = itemStats->getUsing()->getBaseDataMap();
for (std::map<std::string, std::string>::iterator it = parentData.begin(); it != parentData.end(); ++it) {
if (baseData.find(it->first) == baseData.end()) {
baseData[it->first] = it->second;
}
}
}
for (int i=0; i<modTable->rowCount(); ++i) {
for (int j=0; j<modTable->columnCount(); ++j) {
delete modTable->item(i, j);
}
}
modTable->setRowCount(0);
int row = 0;
if (itemStats->getContainerType() == "deltamod") {
StatsContainer *boost = GenStatsReader::getContainer(allItemStats, itemStats->getBoostName());
if (boost != 0) {
std::map<std::string, std::string> boostMap = boost->getBaseDataMap();
for (std::map<std::string, std::string>::iterator it = boostMap.begin(); it != boostMap.end(); ++it) {
if (baseData.find(it->first) == baseData.end()) {
baseData[it->first] = it->second;
}
}
}
for (int i=0; i<itemStats->getPrefixList().size(); ++i) {
QTableWidgetItem *nameItem = new QTableWidgetItem();
nameItem->setFlags(nameItem->flags() & ~Qt::ItemIsEditable);
nameItem->setText("Prefix");
QTableWidgetItem *valueItem = new QTableWidgetItem();
valueItem->setFlags(valueItem->flags() & ~Qt::ItemIsEditable);
valueItem->setText(itemStats->getPrefixList()[i].c_str());
modTable->insertRow(row);
modTable->setItem(row, 0, nameItem);
modTable->setItem(row, 1, valueItem);
++row;
}
for (int i=0; i<itemStats->getSuffixList().size(); ++i) {
QTableWidgetItem *nameItem = new QTableWidgetItem();
nameItem->setFlags(nameItem->flags() & ~Qt::ItemIsEditable);
nameItem->setText("Suffix");
QTableWidgetItem *valueItem = new QTableWidgetItem();
valueItem->setFlags(valueItem->flags() & ~Qt::ItemIsEditable);
valueItem->setText(itemStats->getSuffixList()[i].c_str());
modTable->insertRow(row);
modTable->setItem(row, 0, nameItem);
modTable->setItem(row, 1, valueItem);
++row;
}
}
for (std::map<std::string, std::string>::iterator it = baseData.begin(); it != baseData.end(); ++it) {
QTableWidgetItem *nameItem = new QTableWidgetItem();
nameItem->setFlags(nameItem->flags() & ~Qt::ItemIsEditable);
nameItem->setText(it->first.c_str());
QTableWidgetItem *valueItem = new QTableWidgetItem();
valueItem->setFlags(valueItem->flags() & ~Qt::ItemIsEditable);
valueItem->setText(it->second.c_str());
modTable->insertRow(row);
modTable->setItem(row, 0, nameItem);
modTable->setItem(row, 1, valueItem);
++row;
}
modTable->resizeRowsToContents();
modTable->resizeColumnsToContents();
} else if (current->childCount() == 0) {
bool canEdit = true;
if (current->text(0) == "Abilities") {
canEdit = false;
}
QStringList headerList;
headerList.push_back("Name");
if (canEdit) {
headerList.push_back("Editable Value");
} else {
headerList.push_back("Value");
}
modTable->setHorizontalHeaderLabels(headerList);
for (int i=0; i<modTable->rowCount(); ++i) {
for (int j=0; j<modTable->columnCount(); ++j) {
delete modTable->item(i, j);
}
}
//.........这里部分代码省略.........
示例3: QWidget
void WindowMaterialShadeInspectorView::createLayout()
{
auto hiddenWidget = new QWidget();
this->stackedWidget()->addWidget(hiddenWidget);
auto visibleWidget = new QWidget();
this->stackedWidget()->addWidget(visibleWidget);
auto mainGridLayout = new QGridLayout();
mainGridLayout->setContentsMargins(7, 7, 7, 7);
mainGridLayout->setSpacing(14);
visibleWidget->setLayout(mainGridLayout);
int row = mainGridLayout->rowCount();
QLabel * label = nullptr;
// Name
label = new QLabel("Name: ");
label->setObjectName("H2");
mainGridLayout->addWidget(label, row, 0);
++row;
m_nameEdit = new OSLineEdit();
mainGridLayout->addWidget(m_nameEdit, row, 0, 1, 3);
++row;
// Standards Information
m_standardsInformationWidget = new StandardsInformationMaterialWidget(m_isIP, mainGridLayout, row);
++row;
// Solar Transmittance
label = new QLabel("Solar Transmittance: ");
label->setObjectName("H2");
mainGridLayout->addWidget(label,row++,0);
m_solarTransmittance = new OSQuantityEdit(m_isIP);
connect(this, &WindowMaterialShadeInspectorView::toggleUnitsClicked, m_solarTransmittance, &OSQuantityEdit::onUnitSystemChange);
mainGridLayout->addWidget(m_solarTransmittance,row++,0,1,3);
// Solar Reflectance
label = new QLabel("Solar Reflectance: ");
label->setObjectName("H2");
mainGridLayout->addWidget(label,row++,0);
m_solarReflectance = new OSQuantityEdit(m_isIP);
connect(this, &WindowMaterialShadeInspectorView::toggleUnitsClicked, m_solarReflectance, &OSQuantityEdit::onUnitSystemChange);
mainGridLayout->addWidget(m_solarReflectance,row++,0,1,3);
// Visible Transmittance
label = new QLabel("Visible Transmittance: ");
label->setObjectName("H2");
mainGridLayout->addWidget(label,row++,0);
m_visibleTransmittance = new OSQuantityEdit(m_isIP);
connect(this, &WindowMaterialShadeInspectorView::toggleUnitsClicked, m_visibleTransmittance, &OSQuantityEdit::onUnitSystemChange);
mainGridLayout->addWidget(m_visibleTransmittance,row++,0,1,3);
// Visible Reflectance
label = new QLabel("Visible Reflectance: ");
label->setObjectName("H2");
mainGridLayout->addWidget(label,row++,0);
m_visibleReflectance = new OSQuantityEdit(m_isIP);
connect(this, &WindowMaterialShadeInspectorView::toggleUnitsClicked, m_visibleReflectance, &OSQuantityEdit::onUnitSystemChange);
mainGridLayout->addWidget(m_visibleReflectance,row++,0,1,3);
// Thermal Hemispherical Emissivity
label = new QLabel("Thermal Hemispherical Emissivity: ");
label->setObjectName("H2");
mainGridLayout->addWidget(label,row++,0);
m_thermalHemisphericalEmissivity = new OSQuantityEdit(m_isIP);
connect(this, &WindowMaterialShadeInspectorView::toggleUnitsClicked, m_thermalHemisphericalEmissivity, &OSQuantityEdit::onUnitSystemChange);
mainGridLayout->addWidget(m_thermalHemisphericalEmissivity,row++,0,1,3);
// Thermal Transmittance
label = new QLabel("Thermal Transmittance: ");
label->setObjectName("H2");
mainGridLayout->addWidget(label,row++,0);
m_thermalTransmittance = new OSQuantityEdit(m_isIP);
connect(this, &WindowMaterialShadeInspectorView::toggleUnitsClicked, m_thermalTransmittance, &OSQuantityEdit::onUnitSystemChange);
mainGridLayout->addWidget(m_thermalTransmittance,row++,0,1,3);
// Thickness
label = new QLabel("Thickness: ");
label->setObjectName("H2");
//.........这里部分代码省略.........
示例4: QTableWidget
void FenPrincipale::calcul_manches() {
for (int j = 0; j < this->nbManches; ++j) {
// on initialise la table html pour l'export
QString html = "<table>\n\t<thead>\n\t\t<tr>\n\t\t\t";
html += "<td>"+tr("Place")+"</td>";
html += "<td>"+tr("Équipage")+"</td>";
html += "<td>"+tr("Points")+"</td>";
if (this->typeClmt == CLMT_TEMPS) {
html += "<td>"+tr("Temps réel")+"</td><td>"+tr("Temps compensé")+"</td>";
}
html += "\n\t\t</tr>\n\t</thead>\n\t<tboby>";
// on affiche la table qui va contenir les résultats de la manche
QTableWidget *table = new QTableWidget();
table->verticalHeader()->hide();
table->setSelectionMode(QAbstractItemView::NoSelection);
table->setProperty("table", "manches");
QList<QString> labels;
labels << tr("Place") << tr("Équipage") << tr("Points");
if (this->typeClmt == CLMT_TEMPS) {
table->setColumnCount(5);
labels << tr("Temps réel") << tr("Temps compensé");
table->setMaximumWidth(560 + 20);
table->setMinimumWidth(560 + 20);
table->setColumnWidth(3, 120);
table->setColumnWidth(4, 120);
}
else {
table->setColumnCount(3);
table->setMaximumWidth(320 + 20);
table->setMinimumWidth(320 + 20);
}
table->setColumnWidth(0, 60);
table->setColumnWidth(1, 200);
table->setColumnWidth(2, 60);
table->setHorizontalHeaderLabels(labels);
table->setRowCount(this->nbEquipages);
ui->choisirResultat->insertItem(j+1,
tr("Résultats de la manche %1").arg(QString::number(j+1)));
int nbAffiches = 0; // pour savoir à quelle ligne on en est
// on traite et affiche les équipages
// on traite chaque manche pour attribuer les points aux équipages
for (int i = 0; i < this->nbEquipages; ++i) {
// on recherche tous les équipages non encore traités pour cette
// manches qui ont un tpsCompense minimal
int min = 0;
QList<int> ids;
for (int k = 0; k < this->nbEquipages; ++k) {
Manche m = this->equipages[k].manches[j];
if (m.tpsCompense < 0 || m.points > 0 ) {
// cet équipage a déjà été traité ou n'a pas de place/temps
// (DNF, DNS, OCS, ...)
continue;
}
if (m.tpsCompense < min || min == 0) {
min = m.tpsCompense;
ids.clear();
ids.append(k);
}
else if (m.tpsCompense == min) {
ids.append(k);
}
}
if (min == 0) {
// on n'a pas trouvé d'équipage à traiter (se produit s'il y a
// des équipages DNS, DNF, OCS, ...)
break;
}
for (int l = 0; l < ids.size(); ++l) {
double points = (ids.size()-1.0)/2.0+i+1.0;
this->equipages[ids.at(l)].points += points;
this->equipages[ids.at(l)].pointsOrdonnes.prepend(points);
this->equipages[ids.at(l)].pointsTries.append(points);
this->equipages[ids.at(l)].manches[j].points = points;
// on affiche ces équipages
Equipage e = this->equipages[ids.at(l)];
Manche m = e.manches[j];
QLabel *place = new QLabel(QString::number(i+1));
table->setCellWidget(i+l, 0, place);
QWidget *nomWidget = new QWidget();
QVBoxLayout *nomLayout = new QVBoxLayout();
QLabel *nom = new QLabel(e.nom);
nom->setProperty("label", "nom");
nomLayout->addWidget(nom);
if (this->typeClmt == CLMT_TEMPS) {
QLabel *bateau = new QLabel();
bateau->setText(this->bateaux.value(e.rating.toUpper()).serie
+" ("+QString::number(e.coef)+")");
bateau->setProperty("label", "bateau");
nomLayout->addWidget(bateau);
table->setRowHeight(i+l, 45);
}
nomLayout->setContentsMargins(0, 0, 0, 0);
nomLayout->setSpacing(0);
nomWidget->setLayout(nomLayout);
table->setCellWidget(i+l, 1, nomWidget);
QLabel *pointsi = new QLabel(QString::number(m.points));
table->setCellWidget(i+l, 2, pointsi);
if (this->typeClmt == CLMT_TEMPS) {
QLabel *tpsReel = new QLabel(this->formate_tps(m.tpsReel));
table->setCellWidget(i+l, 3, tpsReel);
//.........这里部分代码省略.........
示例5: KPageDialog
PropertiesDialog::PropertiesDialog(QWidget *parent, Okular::Document *doc)
: KPageDialog( parent ), m_document( doc ), m_fontPage( 0 ),
m_fontModel( 0 ), m_fontInfo( 0 ), m_fontProgressBar( 0 ),
m_fontScanStarted( false )
{
setFaceType( Tabbed );
setCaption( i18n( "Unknown File" ) );
setButtons( Ok );
// PROPERTIES
QFrame *page = new QFrame();
KPageWidgetItem *item = addPage( page, i18n( "&Properties" ) );
item->setIcon( KIcon( "document-properties" ) );
// get document info
const Okular::DocumentInfo info = doc->documentInfo();
QFormLayout *layout = new QFormLayout( page );
// mime name based on mimetype id
QString mimeName = info.get( Okular::DocumentInfo::MimeType ).section( '/', -1 ).toUpper();
setCaption( i18n( "%1 Properties", mimeName ) );
int valMaxWidth = 100;
/* obtains the properties list, conveniently ordered */
QStringList orderedProperties;
orderedProperties << Okular::DocumentInfo::getKeyString( Okular::DocumentInfo::FilePath )
<< Okular::DocumentInfo::getKeyString( Okular::DocumentInfo::PagesSize )
<< Okular::DocumentInfo::getKeyString( Okular::DocumentInfo::DocumentSize );
for (Okular::DocumentInfo::Key ks = Okular::DocumentInfo::Title;
ks <= Okular::DocumentInfo::Keywords;
ks = Okular::DocumentInfo::Key( ks+1 ) )
{
orderedProperties << Okular::DocumentInfo::getKeyString( ks );
}
foreach( const QString &ks, info.keys()) {
if ( !orderedProperties.contains( ks ) ) {
orderedProperties << ks;
}
}
for ( QStringList::Iterator it = orderedProperties.begin();
it != orderedProperties.end();
++it )
{
const QString key = *it;
const QString titleString = info.getKeyTitle( key );
const QString valueString = info.get( key );
if ( titleString.isNull() || valueString.isNull() )
continue;
// create labels and layout them
QWidget *value = NULL;
if ( key == Okular::DocumentInfo::getKeyString( Okular::DocumentInfo::MimeType ) ) {
/// for mime type fields, show icon as well
value = new QWidget( page );
/// place icon left of mime type's name
QHBoxLayout *hboxLayout = new QHBoxLayout( value );
hboxLayout->setMargin( 0 );
/// retrieve icon and place it in a QLabel
KMimeType::Ptr mimeType = KMimeType::mimeType( valueString );
KSqueezedTextLabel *squeezed;
if (!mimeType.isNull()) {
/// retrieve icon and place it in a QLabel
QLabel *pixmapLabel = new QLabel( value );
hboxLayout->addWidget( pixmapLabel, 0 );
pixmapLabel->setPixmap( KIconLoader::global()->loadMimeTypeIcon( mimeType->iconName(), KIconLoader::Small ) );
/// mime type's name and label
squeezed = new KSqueezedTextLabel( i18nc( "mimetype information, example: \"PDF Document (application/pdf)\"", "%1 (%2)", mimeType->comment(), valueString ), value );
} else {
/// only mime type name
squeezed = new KSqueezedTextLabel( valueString, value );
}
squeezed->setTextInteractionFlags( Qt::TextSelectableByMouse );
hboxLayout->addWidget( squeezed, 1 );
} else {
/// default for any other document information
KSqueezedTextLabel *label = new KSqueezedTextLabel( valueString, page );
label->setTextInteractionFlags( Qt::TextSelectableByMouse );
value = label;
}
layout->addRow( new QLabel( i18n( "%1:", titleString ) ), value);
// refine maximum width of 'value' labels
valMaxWidth = qMax( valMaxWidth, fontMetrics().width( valueString ) );
}
// FONTS
QVBoxLayout *page2Layout = 0;
if ( doc->canProvideFontInformation() ) {
// create fonts tab and layout it
QFrame *page2 = new QFrame();
m_fontPage = addPage(page2, i18n("&Fonts"));
m_fontPage->setIcon( KIcon( "preferences-desktop-font" ) );
page2Layout = new QVBoxLayout(page2);
page2Layout->setMargin(marginHint());
page2Layout->setSpacing(spacingHint());
// add a tree view
QTreeView *view = new QTreeView(page2);
view->setContextMenuPolicy(Qt::CustomContextMenu);
//.........这里部分代码省略.........
示例6: updateNetStatus
void DhtWindow::updateNetStatus()
{
QString status;
QString oldstatus;
#if 0
status = QString::fromStdString(mPeerNet->getPeerStatusString());
oldstatus = ui.peerLine->text();
if (oldstatus != status)
{
ui.peerLine->setText(status);
}
#endif
status = QString::fromStdString(rsDht->getUdpAddressString());
oldstatus = ui.peerAddressLabel->text();
if (oldstatus != status)
{
ui.peerAddressLabel->setText(status);
}
uint32_t netMode = rsConfig->getNetworkMode();
QLabel *label = ui.networkLabel;
switch(netMode)
{
case RSNET_NETWORK_UNKNOWN:
label->setText(tr("Unknown NetState"));
break;
case RSNET_NETWORK_OFFLINE:
label->setText(tr("Offline"));
break;
case RSNET_NETWORK_LOCALNET:
label->setText(tr("Local Net"));
break;
case RSNET_NETWORK_BEHINDNAT:
label->setText(tr("Behind NAT"));
break;
case RSNET_NETWORK_EXTERNALIP:
label->setText(tr("External IP"));
break;
}
label = ui.natTypeLabel;
uint32_t natType = rsConfig->getNatTypeMode();
switch(natType)
{
case RSNET_NATTYPE_UNKNOWN:
label->setText(tr("UNKNOWN NAT STATE"));
break;
case RSNET_NATTYPE_SYMMETRIC:
label->setText(tr("SYMMETRIC NAT"));
break;
case RSNET_NATTYPE_DETERM_SYM:
label->setText(tr("DETERMINISTIC SYM NAT"));
break;
case RSNET_NATTYPE_RESTRICTED_CONE:
label->setText(tr("RESTRICTED CONE NAT"));
break;
case RSNET_NATTYPE_FULL_CONE:
label->setText(tr("FULL CONE NAT"));
break;
case RSNET_NATTYPE_OTHER:
label->setText(tr("OTHER NAT"));
break;
case RSNET_NATTYPE_NONE:
label->setText(tr("NO NAT"));
break;
}
label = ui.natHoleLabel;
uint32_t natHole = rsConfig->getNatHoleMode();
switch(natHole)
{
case RSNET_NATHOLE_UNKNOWN:
label->setText(tr("UNKNOWN NAT HOLE STATUS"));
break;
case RSNET_NATHOLE_NONE:
label->setText(tr("NO NAT HOLE"));
break;
case RSNET_NATHOLE_UPNP:
label->setText(tr("UPNP FORWARD"));
break;
case RSNET_NATHOLE_NATPMP:
label->setText(tr("NATPMP FORWARD"));
break;
case RSNET_NATHOLE_FORWARDED:
label->setText(tr("MANUAL FORWARD"));
break;
}
uint32_t connect = rsConfig->getConnectModes();
label = ui.connectLabel;
QString connOut;
//.........这里部分代码省略.........
示例7: throw
// -------------------------------------------------------------------------------------------------
ParameterBox::ParameterBox(QWidget* parent, const char* name)
throw ()
: QFrame(parent, name), m_leftValue(-1.0), m_rightValue(-1.0)
{
QGridLayout* layout = new QGridLayout(this, 5 /* row */, 9 /* col */, 0 /* margin */, 5);
// - create ------------------------------------------------------------------------------------
// settings
Settings& set = Settings::set();
// widgets
QLabel* timeLabel = new QLabel(tr("&Measuring Time:"), this);
QLabel* sampleLabel = new QLabel(tr("&Sampling Rate:"), this);
QLabel* triggerLabel = new QLabel(tr("&Triggering:"), this);
QTimeEdit* timeedit = new QTimeEdit(this);
timeedit->setRange(QTime(0, 0), QTime(0, 1));
QSlider* sampleSlider = new QSlider(0, MAX_SLIDER_VALUE, 1, 0, Qt::Horizontal, this);
TriggerWidget* triggering = new TriggerWidget(this);
// labels for the markers
QLabel* leftMarkerLabel = new QLabel(tr("Left Button Marker:"), this);
QLabel* rightMarkerLabel = new QLabel(tr("Right Button Marker:"), this);
QLabel* diffLabel = new QLabel(tr("Difference:"), this);
m_leftMarker = new QLabel(this);
m_rightMarker = new QLabel(this);
m_diff = new QLabel("zdddd", this);
// set the font for the labels
QFont font = qApp->font(this);
font.setPixelSize(15);
font.setBold(true);
m_leftMarker->setFont(font);
m_rightMarker->setFont(font);
m_diff->setFont(font);
// buddys
timeLabel->setBuddy(timeedit);
triggerLabel->setBuddy(triggering);
sampleLabel->setBuddy(sampleSlider);
// load value
triggering->setValue(set.readNumEntry("Measuring/Triggering/Value"),
set.readNumEntry("Measuring/Triggering/Mask"));
timeedit->setTime(QTime(0, set.readNumEntry("Measuring/Triggering/Minutes"),
set.readNumEntry("Measuring/Triggering/Seconds")));
sampleSlider->setValue(MAX_SLIDER_VALUE - set.readNumEntry("Measuring/Number_Of_Skips"));
// - layout the stuff --------------------------------------------------------------------------
// row, col
layout->addWidget(timeLabel, 0, 1);
layout->addWidget(sampleLabel, 1, 1);
layout->addWidget(triggerLabel, 2, 1, Qt::AlignTop);
layout->addWidget(timeedit, 0, 3);
layout->addWidget(sampleSlider, 1, 3);
layout->addMultiCellWidget(triggering, 2, 3, 3, 3);
layout->addWidget(leftMarkerLabel, 0, 5);
layout->addWidget(rightMarkerLabel, 1, 5);
layout->addWidget(diffLabel, 2, 5);
layout->addWidget(m_leftMarker, 0, 7, Qt::AlignRight);
layout->addWidget(m_rightMarker, 1, 7, Qt::AlignRight);
layout->addWidget(m_diff, 2, 7, Qt::AlignRight);
layout->setColStretch(0, 2);
layout->setColSpacing(2, 20);
layout->setColStretch(4, 4);
layout->setColSpacing(6, 20);
layout->setColSpacing(7, 150);
layout->setColStretch(8, 2);
connect(timeedit, SIGNAL(valueChanged(const QTime&)),
this, SLOT(timeValueChanged(const QTime&)));
connect(triggering, SIGNAL(valueChanged(byte, byte)),
this, SLOT(triggerValueChanged(byte, byte)));
connect(sampleSlider, SIGNAL(valueChanged(int)),
this, SLOT(sliderValueChanged(int)));
// - initial values ----------------------------------------------------------------------------
updateValues();
}
示例8: QDialog
Setup::Setup(QWidget *parent) : QDialog(parent) {
// QMessageBox::information(this,"Need to Setup","This seems to be the first time you start Booker. You need to enter some important information.");
QLabel *title = new QLabel("Setup Booker");
title->setStyleSheet("font-weight: bold; font-size: 12pt");
title->setAlignment(Qt::AlignCenter);
Line *belowTitle = new Line;
QLabel *dbLabel = new QLabel("Please enter here the database connection credentials:");
dbLabel->setWordWrap(true);
dbHost = new QLineEdit;
dbDatabase = new QLineEdit;
dbUsername = new QLineEdit;
dbPassword = new QLineEdit;
QFormLayout *dbLay = new QFormLayout;
dbLay->addRow("Host:",dbHost);
dbLay->addRow("Database:",dbDatabase);
dbLay->addRow("Username:",dbUsername);
dbLay->addRow("Password:",dbPassword);
connect(dbHost, SIGNAL(textEdited(QString)), this, SLOT(updateData()));
connect(dbDatabase, SIGNAL(textEdited(QString)), this, SLOT(updateData()));
connect(dbUsername, SIGNAL(textEdited(QString)), this, SLOT(updateData()));
connect(dbPassword, SIGNAL(textEdited(QString)), this, SLOT(updateData()));
Line *belowDb = new Line;
QLabel *pwLabel = new QLabel("Please enter here the three passwords. The office is the one known to everyone. The Encryption password is supposed to be kept secret and doesn't need to be entered again. The Master Password also doesn't need to be entered, except you want to change some of the configuration.");
pwLabel->setWordWrap(true);
pwMasterCheck = new QCheckBox("Master Password:");
pwOffice = new QLineEdit;
pwMaster = new QLineEdit;
pwMaster->setEnabled(false);
pwEncryption = new QLineEdit;
// pwOffice->setEchoMode(QLineEdit::PasswordEchoOnEdit);
// pwMaster->setEchoMode(QLineEdit::PasswordEchoOnEdit);
// pwEncryption->setEchoMode(QLineEdit::PasswordEchoOnEdit);
QFormLayout *pwLay = new QFormLayout;
pwLay->addRow("Office Password:",pwOffice);
pwLay->addRow("Encryption Password:",pwEncryption);
pwLay->addRow(pwMasterCheck,pwMaster);
connect(pwMasterCheck, SIGNAL(toggled(bool)), pwMaster, SLOT(setEnabled(bool)));
connect(pwMasterCheck, SIGNAL(toggled(bool)), pwEncryption, SLOT(setEnabled(bool)));
connect(pwOffice, SIGNAL(textEdited(QString)), this, SLOT(updateData()));
connect(pwMaster, SIGNAL(textEdited(QString)), this, SLOT(updateData()));
Line *belowPw = new Line;
ok = new QPushButton("Okay");
ok->setEnabled(false);
can = new QPushButton("Quit");
QHBoxLayout *butLay = new QHBoxLayout;
butLay->addStretch();
butLay->addWidget(ok);
butLay->addWidget(can);
butLay->addStretch();
QVBoxLayout *lay = new QVBoxLayout;
lay->addSpacing(5);
lay->addWidget(title);
lay->addSpacing(5);
lay->addWidget(belowTitle);
lay->addSpacing(5);
lay->addWidget(dbLabel);
lay->addSpacing(5);
lay->addLayout(dbLay);
lay->addSpacing(5);
lay->addWidget(belowDb);
lay->addSpacing(5);
lay->addWidget(pwLabel);
lay->addSpacing(5);
lay->addLayout(pwLay);
lay->addSpacing(5);
lay->addWidget(belowPw);
lay->addSpacing(5);
lay->addLayout(butLay);
this->setLayout(lay);
connect(ok, SIGNAL(clicked()), this, SLOT(enter()));
connect(can, SIGNAL(clicked()), this, SLOT(reject()));
}
示例9: QWidget
Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget),
m_pData(new Widget::Private())
{
ui->setupUi(this);
QComboBox *cityList = new QComboBox(this);
cityList->addItem(tr("Beijing"), QLatin1String("Beijing, cn"));
cityList->addItem(tr("Shanghai"), QLatin1String("Shanghai, cn"));
cityList->addItem(tr("Nanjing"), QLatin1String("Nanjing, cn"));
QLabel* cityLabel = new QLabel(tr("City:"), this);
QPushButton *refreshButton = new QPushButton(tr("Refresh"), this);
QHBoxLayout *cityListLayout = new QHBoxLayout;
cityListLayout->setDirection(QBoxLayout::LeftToRight);
cityListLayout->addWidget(cityLabel);
cityListLayout->addWidget(cityList);
cityListLayout->addWidget(refreshButton);
QVBoxLayout *weatherLayout = new QVBoxLayout;
weatherLayout->setDirection(QBoxLayout::TopToBottom);
QLabel* cityNameLabel = new QLabel(this);
weatherLayout->addWidget(cityNameLabel);
QLabel *dateTimeLabel = new QLabel(this);
weatherLayout->addWidget(dateTimeLabel);
m_pData->descLabel = new QLabel(this);
weatherLayout->addWidget(m_pData->descLabel);
m_pData->iconLabel = new QLabel(this);
weatherLayout->addWidget(m_pData->iconLabel);
QVBoxLayout* mainLayout = new QVBoxLayout(this);
mainLayout->addLayout(cityListLayout);
mainLayout->addLayout(weatherLayout);
resize(320, 120);
setWindowTitle("Weather");
connect(m_pData->network, &NetWorker::finished, [=](QNetworkReply* reply){
switch(m_pData->replyMap.value(reply))
{
case FetchWeatherInfo:
{
QJsonParseError error;
QJsonDocument jsonDoc = QJsonDocument::fromJson(reply->readAll(), &error);
if(error.error == QJsonParseError::NoError){
if(!(jsonDoc.isNull() || jsonDoc.isEmpty()) && (jsonDoc.isObject())){
QVariantMap data = jsonDoc.toVariant().toMap();
WeatherInfo weather;
weather.setCityName(data[QLatin1String("name")].toString());
QDateTime dateTime;
dateTime.setTime_t(data[QLatin1String("dt")].toLongLong());
weather.setDateTime(dateTime);
QVariantMap main = data[QLatin1String("main")].toMap();
weather.setTempertuare(main[QLatin1String("temp")].toFloat());
weather.setPressure(main[QLatin1String("pressure")].toFloat());
weather.setHumidity(main[QLatin1String("humidity")].toFloat());
QVariantList detaiList = data[QLatin1String("weather")].toList();
WeatherDetailList details;
foreach (QVariant w, detaiList) {
QVariantMap wm = w.toMap();
WeatherDetail *detail = new WeatherDetail;
detail->setDesc(wm[QLatin1String("description")].toString());
detail->setIcon(wm[QLatin1Literal("icon")].toString());
details.append(detail);
}
weather.setDetails(details);
cityNameLabel->setText(weather.cityName());
dateTimeLabel->setText(weather.dateTime().toString(Qt::DefaultLocaleLongDate));
m_pData->descLabel->setText(weather.details().at(0)->desc());
qDebug()<<weather;
}
else{
QMessageBox::critical(this, "Error","Parse Reply Error!");
}
}
}
示例10: QWidget
CFullTestIOInWindow::CFullTestIOInWindow(QWidget *parent) :
QWidget(parent)
{
setProperty("testFlag",0);
setProperty("init",0);
setProperty("in",0);
cf = ((CApp*)qApp)->_tjob->_mconfig;
_ioItemCount = cf->_map_ioin.size();
if(!property("init").toInt())
{
setProperty("init",1);
QVBoxLayout *top = new QVBoxLayout;
for(int i=0; i != _ioItemCount; ++i)
{
QLabel *_tempLabel = new QLabel;
_tempLabel->setStyleSheet("border-radius:20px;background:#fff;border:1px solid #666;");
_tempLabel->setFixedSize(40,40);
_vec32IO.push_back(_tempLabel);
}
_testButton1 = new QPushButton(tr("检测低电平"));
_testButton2 = new QPushButton(tr("检测高电平"));
_statusLabel = new QLabel(tr("点击高低电平测试所有通道,点击圆圈发生检测单个通道。"));
_statusLabel->setStyleSheet("font:bold 16px;color:#0099FF;max-height:26px;min-height:26px;background:#CCFF99;");
_statusLabel_1 = new QLabel(tr("当前电平为:"));
_statusLabel_1->setStyleSheet("font:bold 18px;color:#0099FF;max-height:30px;min-height:30px;background:#CCFF99;");
_testButton1->setFocusPolicy(Qt::NoFocus);
_testButton2->setFocusPolicy(Qt::NoFocus);
_bReadCurrent = new QCheckBox("读取激励电流");
_bReadCurrent->setFocusPolicy(Qt::NoFocus);
//***Layout
QGroupBox *_mainGroupBox = new QGroupBox(QString::number(_ioItemCount) + tr("路IO输入量测试"));
QGridLayout *_mainGridLay = new QGridLayout(_mainGroupBox);
_mainGridLay->addWidget(_statusLabel,0,0,1,8);
_mainGridLay->addWidget(_statusLabel_1,1,0,1,8);
for(int i=0; i != _ioItemCount; ++i)
{
QVBoxLayout *_tempVLay = new QVBoxLayout;
int kk = ((CApp*)qApp)->_tjob->getIOInMapVoltage(i);
QLabel *io = new QLabel( kk?tr("高电平有效"):tr("低电平有效") );
if(kk)
io->setStyleSheet("background-color:wheat;");
else
io->setStyleSheet("background-color:yellow;");
_vec32IO[i]->installEventFilter(this);
_tempVLay->addWidget(new QLabel("I/O量"+QString("%1").arg(i)));
_tempVLay->addWidget(_vec32IO.at(i));
_tempVLay->addWidget(io);
_mainGridLay->addLayout(_tempVLay,i/8+2,i%8,1,1);
if( ((CApp*)qApp)->_tjob->getIOInMapCurrent(i)!=-1 )
_vec32IO[i]->setText(tr("电流"));
}
_mainGridLay->addWidget(_bReadCurrent,6,2,1,2);
_mainGridLay->addWidget(_testButton1,6,4,1,2);
_mainGridLay->addWidget(_testButton2,6,6,1,2);
top->addWidget(_mainGroupBox);
top->setSizeConstraint(QLayout::SetFixedSize);
setLayout(top);
//***Signal
connect(_testButton1,SIGNAL(clicked()),this,SLOT(testButton1Clicked()));
connect(_testButton2,SIGNAL(clicked()),this,SLOT(testButton2Clicked()));
connect((CApp*)qApp,SIGNAL(sendBackFullTestData_ioi_485(QByteArray)),this,SLOT(sendBackData485(QByteArray)));
connect((CApp*)qApp,SIGNAL(sendBackFullTestData_ioi_232(QByteArray)),this,SLOT(sendBackData232(QByteArray)));
}
}
示例11: QMainWindow
/**
* @brief MainWindow that displays the interface for the program.
* @param parent parent widget of mainwindow = 0
*/
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
this->setWindowTitle("MilaOCRv1.0.0");
// create all layouts
QWidget* main_window=new QWidget;//create a central widget
QVBoxLayout* vlayout1 = new QVBoxLayout;//main layout for application
QHBoxLayout* hlayout1 = new QHBoxLayout;//create top horizontal layout, for buttons
QHBoxLayout* hlayout2 = new QHBoxLayout;//middle horiz layout, img + text boxes
QHBoxLayout* hlayout3 = new QHBoxLayout;//bottom horiz layout, export button
QVBoxLayout* vlayout2 = new QVBoxLayout;//layout for file and ocr buttons
QLabel* header = new QLabel("<h3>MilaOCR</h3>");
QPixmap pic(":/Image/MilaOCR.png");
//to set buttons as icons with pictures
//QPixmap import_pic(":/Image/importfile.png");
//QPixmap export_pic(":/Image/export.png");
//QIcon export_icon(export_pic);
//QIcon import_icon(import_pic);
header->setPixmap(pic);
header->setAlignment(Qt::AlignCenter);
QPushButton* openFileButton = new QPushButton("Choose File");//open file button
openFileButton->setFixedWidth(150);
//openFileButton->setFont(QFont::);
//openFileButton->setIcon(import_icon);
//openFileButton->setIconSize(import_pic.size());
//set tooltip
openFileButton->setToolTip("Max file size: 1MB");
QPushButton* performOCR = new QPushButton("Perform OCR");//perform OCR button
performOCR->setFixedWidth(150);
//set tooltip
performOCR->setToolTip("Click to perform OCR and see results");
QPushButton* exportToFile = new QPushButton("Export");//export button
exportToFile->setFixedWidth(100);
//exportToFile->setIcon(export_icon);
//exportToFile->setIconSize(export_pic.size());
//set tooltip
exportToFile->setToolTip("Save the results to a text file");
//Qlabels to hold OCR image and OCR'd text
displayImage->setStyleSheet("border: 1.4px solid black");
displayImage->setFixedSize(350,400);
displayImage->setScaledContents(true);
displayText->setStyleSheet("border: 1.4px solid black");
displayText->setFixedSize(350,400);
displayText->setScaledContents(true);
//set signals and slots for buttons
QObject::connect(openFileButton,SIGNAL(clicked()),this,SLOT(chooseFile()));
QObject::connect(performOCR,SIGNAL(clicked()),this,SLOT(recognize()));
QObject::connect(exportToFile,SIGNAL(clicked()),this,SLOT(saveToFile()));
//add everything to layouts
vlayout2->addWidget(openFileButton);
vlayout2->addWidget(performOCR);
hlayout2->addWidget(displayImage);
hlayout2->addLayout(vlayout2);
hlayout2->addWidget(displayText);
hlayout3->addWidget(exportToFile);
hlayout3->setAlignment(Qt::AlignRight);
//add everything to main layout
vlayout1->addWidget(header);
vlayout1->addLayout(hlayout1);
vlayout1->addLayout(hlayout2);
vlayout1->addLayout(hlayout3);
main_window->setLayout(vlayout1);
//set central widget
this->setCentralWidget(main_window);
}
示例12: QLabel
void SettingsWindow::genCustomise()
{
QLabel *lblBgColor = new QLabel(tr("Background color"));
lblBgColor->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum);
editBgColor = new QLineEdit;
editBgColor->setEnabled(false);
editBgColor->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum);
QToolButton *btnBgColor = new QToolButton;
btnBgColor->setText(tr("Change color"));
btnBgColor->setIcon(QIcon(":/img/config.png"));
btnBgColor->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
btnBgColor->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum);
connect(btnBgColor,SIGNAL(clicked()),this,SLOT(chooseColor()));
QLabel *lblBgImageMain = new QLabel(tr("Background image of the main window"));
editBgImageMain = new QLineEdit;
editBgImageMain->setEnabled(false);
editBgImageMain->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum);
btnBgImageMain = new QToolButton;
btnBgImageMain->setText(tr("Explore"));
btnBgImageMain->setIcon(QIcon(":/img/config.png"));
btnBgImageMain->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
btnBgImageMain->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum);
connect(btnBgImageMain,SIGNAL(clicked()),this,SLOT(chooseBgImage()));
QLabel *lblBgImageLock = new QLabel(tr("Background image of the lock screen"));
editBgImageLock = new QLineEdit;
editBgImageLock->setEnabled(false);
editBgImageLock->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum);
btnBgImageLock = new QToolButton;
btnBgImageLock->setText(tr("Explore"));
btnBgImageLock->setIcon(QIcon(":/img/config.png"));
btnBgImageLock->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
btnBgImageLock->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum);
connect(btnBgImageLock,SIGNAL(clicked()),this,SLOT(chooseBgImage()));
QLabel *lblAnimation = new QLabel(tr("Animations Effects / Transitions"));
checkAnimation = new QCheckBox(tr("Enable"));
checkAnimation->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum);
QGridLayout *layCustomise = new QGridLayout;
layCustomise->setContentsMargins(10,10,10,10);
layCustomise->setSpacing(10);
layCustomise->addWidget(lblAnimation,0,0);
layCustomise->addWidget(checkAnimation,0,1,1,2);
layCustomise->addWidget(lblBgColor,1,0);
layCustomise->addWidget(editBgColor,1,1);
layCustomise->addWidget(btnBgColor,1,2);
layCustomise->addWidget(lblBgImageMain,2,0);
layCustomise->addWidget(editBgImageMain,2,1);
layCustomise->addWidget(btnBgImageMain,2,2);
layCustomise->addWidget(lblBgImageLock,3,0);
layCustomise->addWidget(editBgImageLock,3,1);
layCustomise->addWidget(btnBgImageLock,3,2);
QGroupBox *boxCustomize = new QGroupBox(tr("Customize"));
boxCustomize->setLayout(layCustomise);
// ----------------------------
previewBgImageMain = new QToolButton;
previewBgImageMain->setText(tr("Background image of the main window"));
previewBgImageMain->setIconSize(QSize(400,300));
previewBgImageMain->setIcon(QIcon(":/img/file.png"));
previewBgImageMain->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
previewBgImageMain->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum);
connect(previewBgImageMain,SIGNAL(clicked()),this,SLOT(chooseBgImage()));
previewBgImageLock = new QToolButton;
previewBgImageLock->setText(tr("Background image of the lock screen"));
previewBgImageLock->setIconSize(QSize(400,300));
previewBgImageLock->setIcon(QIcon(":/img/file.png"));
previewBgImageLock->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
previewBgImageLock->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum);
connect(previewBgImageLock,SIGNAL(clicked()),this,SLOT(chooseBgImage()));
QGridLayout *layBgImageMain = new QGridLayout;
layBgImageMain->setContentsMargins(10,10,10,10);
layBgImageMain->setSpacing(10);
layBgImageMain->addWidget(previewBgImageMain,0,0);
layBgImageMain->addWidget(previewBgImageLock,0,1);
HideBlock *boxBgImage = new HideBlock(tr("Background images preview"));
boxBgImage->setBlockLayout(layBgImageMain);
// ----------------------------
QWidget *spacer = new QWidget;
spacer->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
QGridLayout *mainLayout = new QGridLayout;
mainLayout->setSpacing(0);
mainLayout->setContentsMargins(0,0,0,0);
mainLayout->addWidget(boxCustomize,0,0);
mainLayout->addWidget(boxBgImage,1,0);
//.........这里部分代码省略.........
示例13: QRadioButton
void SettingsWindow::genNavigation()
{
radioEmptyStartup = new QRadioButton(tr("Show empty page"));
radioHomeStartup = new QRadioButton(tr("Show home page"));
radioSpecificStartup = new QRadioButton(tr("Show specific page"));
editSpecificStartup = new QLineEdit;
editSpecificStartup->hide();
QGridLayout *layStartup = new QGridLayout;
layStartup->setContentsMargins(10,10,10,10);
layStartup->setSpacing(10);
layStartup->addWidget(radioEmptyStartup,0,0);
layStartup->addWidget(radioHomeStartup,1,0);
layStartup->addWidget(radioSpecificStartup,2,0);
layStartup->addWidget(editSpecificStartup,3,1);
connect(radioSpecificStartup,SIGNAL(toggled(bool)),editSpecificStartup,SLOT(setVisible(bool)));
HideBlock *boxStartup = new HideBlock(tr("At startup"));
boxStartup->setBlockLayout(layStartup);
// -----------------------------------------
radioEmptyNewTab = new QRadioButton(tr("Show empty page"));
radioHomeNewTab = new QRadioButton(tr("Show home page"));
radioSpecificNewTab = new QRadioButton(tr("Show specific page"));
editSpecificNewTab = new QLineEdit;
editSpecificNewTab->hide();
QGridLayout *layNewTab = new QGridLayout;
layNewTab->setContentsMargins(10,10,10,10);
layNewTab->setSpacing(10);
layNewTab->addWidget(radioEmptyNewTab,0,0);
layNewTab->addWidget(radioHomeNewTab,1,0);
layNewTab->addWidget(radioSpecificNewTab,2,0);
layNewTab->addWidget(editSpecificNewTab,3,1);
connect(radioSpecificNewTab,SIGNAL(toggled(bool)),editSpecificNewTab,SLOT(setVisible(bool)));
HideBlock *boxNewTab = new HideBlock(tr("When I open a new tab"));
boxNewTab->setBlockLayout(layNewTab);
// -----------------------------------------
QLabel *lblHomePage = new QLabel(tr("Home page"));
lblHomePage->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum);
editHomePage = new QLineEdit;
QLabel *lblSearchUrl = new QLabel(tr("Search URL"));
editPrefixSearchUrl = new QLineEdit;
QLabel *lblSearch = new QLabel(tr("search words"));
editSuffixSearchUrl = new QLineEdit;
QGridLayout *layNavigationUrl = new QGridLayout;
layNavigationUrl->setContentsMargins(10,10,10,10);
layNavigationUrl->setSpacing(10);
layNavigationUrl->addWidget(lblHomePage,0,0);
layNavigationUrl->addWidget(editHomePage,0,1,1,3);
layNavigationUrl->addWidget(lblSearchUrl,1,0);
layNavigationUrl->addWidget(editPrefixSearchUrl,1,1);
layNavigationUrl->addWidget(lblSearch,1,2);
layNavigationUrl->addWidget(editSuffixSearchUrl,1,3);
QGroupBox *boxNavigationUrl = new QGroupBox(tr("URL Navigations"));
boxNavigationUrl->setLayout(layNavigationUrl);
// -------------------------------------
// GrpBox Navigation (normal/private/perso)
// ---------------------------------------
QWidget *spacer = new QWidget;
spacer->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
QGridLayout *mainLayout = new QGridLayout;
mainLayout->setSpacing(0);
mainLayout->setContentsMargins(0,0,0,0);
mainLayout->addWidget(boxNavigationUrl);
mainLayout->addWidget(boxStartup);
mainLayout->addWidget(boxNewTab);
mainLayout->addWidget(spacer);
tabNavigation = new SettingsPanel;
tabNavigation->setTitle(tr("Navigation"));
tabNavigation->setMainLayout(mainLayout);
}
示例14: setWindowFlags
mainWindow::mainWindow()
{
this->resize(440, 280);
setWindowFlags(Qt::FramelessWindowHint);
QLabel *background = new QLabel(this);
background->setStyleSheet("background-color:lightblue");
background->setGeometry(0,0,this->width(),this->height());
int width = this->width();
QToolButton *minButton = new QToolButton(this);
QToolButton *closeButton = new QToolButton(this);
connect(minButton,SIGNAL(clicked()),this,SLOT(showMinimized()));
connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
minButton->setGeometry(width-50,5,20,20);
closeButton->setGeometry(width-25,5,20,20);
QPixmap minPix = style()->standardPixmap(QStyle::SP_TitleBarMinButton);
QPixmap closePix = style()->standardPixmap(QStyle::SP_TitleBarCloseButton);
minButton->setIcon(minPix);
closeButton->setIcon(closePix);
minButton->setToolTip(tr("最小化"));
closeButton->setToolTip(tr("关闭"));
minButton->setStyleSheet("background-color:transparent");
closeButton->setStyleSheet("background-color:transparent;");
nickNameLabel.setParent(this); //昵称处
nickNameLabel.setGeometry(QRect(30, 10, 50, 25));
nickNameLabel.setText("昵称");
tipLabel.setParent(this); //建议框
tipLabel.setGeometry(QRect(100, 10, 220, 25));
tipLabel.setText("您今天背诵了XX个单词");
time.setParent(this);
time.setGeometry(320, 10, 60, 25);
QTimer *timer1 = new QTimer(this);
timer1->start(1000);
connect(timer1, SIGNAL(timeout()), this, SLOT(tim_slot()));
inquireEdit.setParent(this); //查询区
inquireEdit.setGeometry(QRect(40, 60, 280, 30));
inquireEdit.setText("请输入要查询的文本");
inquireEdit.setFocus();
search.setParent(this); //搜索按钮
search.setGeometry(QRect(330, 60, 100, 30));
search.setText("开始查询");
dayEnglish_1.setParent(this); //每日英语
dayEnglish_1.setGeometry(QRect(0, 100, 160, 220));
dayEnglish_1.setWordWrap(true);
dayEnglish_1.setAlignment(Qt::AlignTop);
dayEnglish_1.setText("每\n日\n英\n语\n区");
dayEnglish_1.setStyleSheet("background-color:lightgreen");
wordEnglish_2.setParent(this); //单词专区
wordEnglish_2.setGeometry(QRect(160, 100,160, 220));
wordEnglish_2.setWordWrap(true);
wordEnglish_2.setAlignment(Qt::AlignTop);
wordEnglish_2.setText("英\n语\n单\n词\n区");
wordEnglish_2.setStyleSheet("background-color:lightyellow");
testEnglish_3.setParent(this); //测试专区
testEnglish_3.setGeometry(QRect(320, 100, 160, 220));
testEnglish_3.setWordWrap(true);
testEnglish_3.setAlignment(Qt::AlignTop);
testEnglish_3.setStyleSheet("background-color:purple");
testEnglish_3.setText("英\n语\n测\n试\n区");
}
示例15: QDialog
MainDialog::MainDialog(QWidget *parent)
: QDialog(parent)
, mHostEdit(new QLineEdit)
, mPortEdit(new QLineEdit)
, mUserEdit(new QLineEdit)
, mPswdEdit(new QLineEdit)
, mLAddrEdit(new QLineEdit)
, mLPortEdit(new QLineEdit)
, mWaitEdit(new QLineEdit)
, mCtrlBtn(new QPushButton(tr("Start")))
, mQuitBtn(new QPushButton(tr("Quit")))
, mLogList(new QListWidget)
, mInfoIcon(QPixmap(":/icon-info.png"))
, mWarnIcon(QPixmap(":/icon-warn.png"))
, mErrorIcon(QPixmap(":/icon-error.png"))
, mStoppedIcon(QPixmap(":/icon-stopped.png"))
, mConnectingIcon(QPixmap(":/icon-connecting.png"))
, mConnectedIcon(QPixmap(":/icon-connected.png"))
, mSleepingIcon(QPixmap(":/icon-sleeping.png"))
, mSettings(new QSettings(QSettings::IniFormat, QSettings::UserScope,
"glacjay", "sshproxy", this))
, mIsKeepRunning(false)
, mProcess(new QProcess(this))
, mRestartTimer(new QTimer(this))
{
setWindowTitle(tr("SSH Proxy"));
setWindowIcon(mConnectedIcon);
mHostEdit->setText(mSettings->value("ssh/host").toString());
mPortEdit->setText(mSettings->value("ssh/port", "22").toString());
mUserEdit->setText(mSettings->value("ssh/user").toString());
mLAddrEdit->setText(mSettings->value("ssh/laddr", "127.0.0.1").toString());
mLPortEdit->setText(mSettings->value("ssh/lport", "1077").toString());
mWaitEdit->setText(mSettings->value("ssh/wait", "10").toString());
mPortEdit->setValidator(new QIntValidator(1, 65535));
mPswdEdit->setEchoMode(QLineEdit::Password);
mLPortEdit->setValidator(new QIntValidator(1, 65535));
mWaitEdit->setValidator(new QIntValidator);
mLogList->setWordWrap(true);
mProcess->setProcessChannelMode(QProcess::MergedChannels);
QLabel *hostLabel = new QLabel(tr("SSH Host:"));
hostLabel->setBuddy(mHostEdit);
QLabel *portLabel = new QLabel(tr("SSH Port:"));
portLabel->setBuddy(mPortEdit);
QLabel *userLabel = new QLabel(tr("Username:"));
userLabel->setBuddy(mUserEdit);
QLabel *pswdLabel = new QLabel(tr("Password:"));
pswdLabel->setBuddy(mPswdEdit);
QLabel *lAddrLabel = new QLabel(tr("Listen Addr:"));
lAddrLabel->setBuddy(mLAddrEdit);
QLabel *lPortLabel = new QLabel(tr("Listen Port:"));
lPortLabel->setBuddy(mLPortEdit);
QLabel *waitLabel = new QLabel(tr("Seconds wait to reconnect:"));
waitLabel->setBuddy(mWaitEdit);
QVBoxLayout *inputLayout = new QVBoxLayout;
inputLayout->addWidget(hostLabel);
inputLayout->addWidget(mHostEdit);
inputLayout->addWidget(portLabel);
inputLayout->addWidget(mPortEdit);
inputLayout->addWidget(userLabel);
inputLayout->addWidget(mUserEdit);
inputLayout->addWidget(pswdLabel);
inputLayout->addWidget(mPswdEdit);
inputLayout->addWidget(lAddrLabel);
inputLayout->addWidget(mLAddrEdit);
inputLayout->addWidget(lPortLabel);
inputLayout->addWidget(mLPortEdit);
inputLayout->addWidget(waitLabel);
inputLayout->addWidget(mWaitEdit);
inputLayout->insertStretch(-1);
inputLayout->addWidget(mCtrlBtn);
inputLayout->addWidget(mQuitBtn);
QGroupBox *inputGroup = new QGroupBox(tr("Settings"));
inputGroup->setLayout(inputLayout);
QVBoxLayout *logLayout = new QVBoxLayout;
logLayout->addWidget(mLogList);
QGroupBox *logGroup = new QGroupBox(tr("Log"));
logGroup->setLayout(logLayout);
QSplitter *splitter = new QSplitter(Qt::Horizontal);
splitter->addWidget(inputGroup);
splitter->addWidget(logGroup);
splitter->setStretchFactor(1, 5);
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addWidget(splitter);
setLayout(mainLayout);
resize(1000, 600);
connect(mCtrlBtn, SIGNAL(clicked(void)), this, SLOT(on_mCtrlBtn_clicked(void)));
connect(mQuitBtn, SIGNAL(clicked(void)), this, SLOT(onQuit(void)));
//.........这里部分代码省略.........