本文整理汇总了C++中QLabel::setGeometry方法的典型用法代码示例。如果您正苦于以下问题:C++ QLabel::setGeometry方法的具体用法?C++ QLabel::setGeometry怎么用?C++ QLabel::setGeometry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QLabel
的用法示例。
在下文中一共展示了QLabel::setGeometry方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QDialog
SetDialog::SetDialog(QWidget *parent): QDialog(parent) {
btnRadioComputer = new QRadioButton("Computer First",this);
btnRadioPlayer = new QRadioButton("Player First",this);
btnApply = new QPushButton(this);
btnRadioComputer->setGeometry(QRect(10,10,140,15));
btnRadioPlayer->setGeometry(QRect(150,10,140,15));
QLabel* diffTxt = new QLabel(this);
diffTxt->setText(tr("Difficult Level:"));
diffTxt->setGeometry(QRect(10,30,140,15));
difficult = new QSlider(Qt::Horizontal,this);
difficult->setGeometry(QRect(130,30,140,15));
difficult->setRange(5,20);
difficult->setValue(20);
QLabel* sizeTxt = new QLabel(this);
sizeTxt->setText(tr("BoardSize:"));
sizeTxt->setGeometry(QRect(10,50,140,15));
sizeBox = new QSpinBox(this);
sizeBox->setGeometry(QRect(130,50,140,30));
sizeBox->setRange(4,10);
sizeBox->setValue(4);
btnApply->setGeometry(QRect(10,170, 93, 27));
btnApply->setText(tr("Apply"));
this->setGeometry(QRect(10,10,300,300));
QObject::connect(btnRadioComputer,SIGNAL(clicked(bool)),this,SLOT(setComputerFirst()));
QObject::connect(btnRadioPlayer,SIGNAL(clicked()),this,SLOT(setPlayerFirst()));
QObject::connect(difficult,SIGNAL(valueChanged(int)),this,SLOT(changeDifficultLevel(int)));
QObject::connect(sizeBox,SIGNAL(valueChanged(int)),this,SLOT(changeBoardSize(int)));
}
示例2: aboutInit
void About::aboutInit()
{
setModal(true);
resize(400, 400);
setWindowTitle("About");
setWindowIcon(QIcon("icons/backupsoft.png"));
QWidget *icon = new QWidget(this);
icon->setStyleSheet("background-image: url(icons/backupsoft.png)");
icon->setGeometry(250 , 10, 100, 100);
QLabel *title = new QLabel("BackupSoft", this);
title->setFont(QFont("Helvetica", 25, 10, false));
title->setGeometry(10, 10, 200, 30);
QLabel *version = new QLabel("Copyright 2010 by\nMichael Kohler and Fabian Gammenthaler\n\nVersion: 1.0", this);
version->setFont(QFont("Helvetica", 8, 2, false));
version->setGeometry(10, 70, 200, 55);
QTextEdit *licence = new QTextEdit(this);
licence->setGeometry(10, 160, 380, 230);
licence->setReadOnly(true);
QFile *file = new QFile("licence.txt");
if (file->open(QIODevice::ReadOnly)) {
QTextStream *stream = new QTextStream(file);
licence->setText(stream->readAll());
}
else {
QString errorMsg = "Could not open licence.txt.. Please make sure it is existent and readable.";
AlertWindow *alertWin = new AlertWindow("ERROR", "", errorMsg);
alertWin->show();
}
}
示例3: layout
void ProgView::layout() {
int maxHeight = 0;
for (int i = 0; i < channelBar.size(); i++) {
int y = 0;
QLabel *chan = channelBar.at(i);
int x = getX(i);
int width = getKey(CHANNEL_WIDTH).toInt();
int height = chan->heightForWidth(width);
if (height > maxHeight) {
maxHeight = height;
}
chan->setGeometry(x, y, width, height);
chan->show();
//qDebug() << "x: " << x << "y: " << y;
//qDebug() << chan->text();
}
CHANNELBAR_HEIGHT.def = maxHeight;
setKey(CHANNELBAR_HEIGHT);
for (int i = 0; i < timeLine.size(); i++) {
int x = 0;
QLabel *lab = timeLine.at(i);
int y = getY(timeLineDate.value(lab));
lab->setGeometry(x, y, lab->sizeHint().width(),
lab->sizeHint().height());
lab->show();
//qDebug() << "x: " << x << "y: " << y;
//qDebug() << lab->text();
}
}
示例4: file
void menu:: score()
{
QFile file("D:/Maze_score.txt");
QString r ;
r="";
int k=1 ;
file.open(QIODevice::ReadOnly | QIODevice::Text);
QTextStream flux(&file);
while(!flux.atEnd() && k<=5)
{
QString temp = flux.readLine();
r+="Score";
r+=QString::number(k);
r+=" : ";
if(temp.toInt()>9)
r+=temp;
else
{
r+="0"+temp;
}
r+="\n";
k++ ;
}
if(k<=5)
{
for(int i=k;i<=5;i++)
{
r+="Score";
r+=QString::number(i);
r+=" : 00\n" ;
}
}
file.close();
score_page = new QWidget();
score_page->setFixedSize(320,500);
score_page->setWindowTitle("ScoreBoard");
score_page->setWindowIcon(QIcon(":/img/menu_icon.png"));
QLabel *bg = new QLabel(score_page);
bg->setGeometry(0,0,320,500);
QPixmap *bgP = new QPixmap(":/img/scoreboard.png");
bg->setPixmap(*bgP);
bg->raise();
QLabel *board = new QLabel(score_page);
board->setGeometry(0,250,320,250);
QString text=r ;
board->setText(text);
board->setAlignment(Qt::AlignCenter);
board->setFont(QFont("Elephant",20,5,false));
board->setStyleSheet("QLabel {color : white; }");
board->raise();
score_page->show();
}
示例5: insertWord
void newWordManageWindow::insertWord(QString spell, QString meaning)
{
QDialog *dialog = new QDialog(addDialog);
dialog->setWindowTitle("重复");
dialog->resize(200, 110);
QLabel *label = new QLabel(dialog);
QLabel *labelText = new QLabel(dialog);
label->setStyleSheet("background-color:lightblue");
labelText->setAlignment(Qt::AlignCenter);
labelText->setGeometry(30, 0, 140, 70);
label->setGeometry(0, 0, this->width(), this->height());
QPushButton *yesButton = new QPushButton(dialog);
yesButton->setGeometry(140, 70, 55, 20);
yesButton->setText("返回");
yesButton->setStyleSheet("color:black");
bool fail = false;
if(spell.size()==0)
{
labelText->setText("单词不能为空!");
fail = true;
}
else if(meaning.size()==0)
{
labelText->setText("释义不能为空!");
fail = true;
}
for(int i=0; i<newWordList.size(); i++)
{
if(newWordList[i].spell==spell)
{
labelText->setText("您已经添加过这个生词了!");
}
fail = true;
break;
}
if(fail)
{
dialog->show();
connect(yesButton,SIGNAL(clicked()), dialog, SLOT(close()));
}
if(!fail)
{
QDateTime sysTime = QDateTime::currentDateTime();
QStringList list = sysTime.toString("yyyy-MM-dd").split('-');
QString time = list[0]+list[1]+list[2];
NEWWORD newword = { meaning, spell, time };
newWordList.push_front(newword);
qDebug() << currentPage << " " << TotalPages;
update();
}
}
示例6: QPushButton
void CreateVmlist::VmFactory()
{
vmslist.clear();
labels.clear();
QPalette p;
p.setColor(QPalette::WindowText,Qt::white);
int m = 0;
for(int i=0;i < nums_vm;i++,m++)
{
//QPushButton *btton = new QPushButton(QIcon("./images/a_detailed.png"),Vmgs[i].at(0)+"\nv"+Vmgs[i].at(1)/*+"\n"+Vmgs[i].at(2)*/,this);
QPushButton *btton = new QPushButton(this);
QLabel *label = new QLabel(this);
label->setStyleSheet("font-size:14px");
btton->setFlat(true);
btton->setFocusPolicy(Qt::NoFocus);
setButtonBackImage(btton,"./images/a_detailed.png",60,60);
if((Vmgs[i].at(0)).length() > 13)
{
QString name = Vmgs[i].at(0);
QString name_0 = name.mid(0,13),name_1=name.mid(13,name.length()-13),name_2="";
//if(name_1.length()>8)
// {name_2 = name_1.mid(8,name_1.length()-8);
// name_1 = name_1.mid(0,8);
// }
//if(name_2.length() > 0)
//label->setText(name_0+"\n "+name_1+"\n "+name_2+"\n\nVDI_"+Vmgs[i].at(1));
//else
label->setText(name_0+"\n "+name_1+"\n\nVDI_"+Vmgs[i].at(1));
}
else
label->setText(Vmgs[i].at(0)+"\n\nVDI_"+Vmgs[i].at(1));
label->setPalette(p);
btngp->addButton(btton,i);
vmslist.push_back(btton);
labels.push_back(label);
if(i%6 == 0)
{
m = 0;
}
/***********more than 6 ************/
if(nums_vm >= 6)
{
btton->setGeometry(x()+130*m+lskey,y()+170*(i/6),60,60);
label->setGeometry(x()+130*m+lskey,y()+60+170*(i/6),120,60);
}
else
{
btton->setGeometry(x()+130*i+lskey,y(),60,60);
label->setGeometry(x()+130*i+lskey,y()+60,120,60);
}
}
repaint();
}
示例7: outline
void outline(QWidget *baseWidget, int xPos, int yPos, int Pos)
{
QLabel *outLabel = new QLabel(baseWidget);
if(!Pos)
outLabel->setGeometry(xPos,yPos,552,20); //Horizontal Borders
else
outLabel->setGeometry(xPos,yPos,20,512); //Vertical Borders
outLabel->setStyleSheet("QLabel { background-color :rgb(170, 170, 127); color : black; }");
}
示例8: pixmap
AboutDialog::AboutDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::AboutDialog)
{
this->setWindowFlags(Qt::Window | Qt::FramelessWindowHint);
setGeometry(0, 0, SC_ABOUT_WIDTH, SC_ABOUT_HEIGHT);
QPixmap pixmap(SC_ABOUT_IMAGE);
setMask(pixmap.mask());
QPalette palette;
palette.setBrush(QPalette::Background, pixmap);
setPalette(palette);
QString qstrVersion = "<span style=\"font-family:" + QString(SC_BOLD_FONT_NAME) + "\">" +
tr("stealth") +
"<span style=\"color:" + QString(SC_MAIN_COLOR_BLUE) +
";\">" + tr("client") + "</span> " +
"<span style=\"color:" + QString(SC_MAIN_COLOR_GREY) +
";\"> V " + QString::fromStdString(FormatVersionNumbers()) +
"</span></span>";
QLabel* lblVersion = new QLabel(this);
QFont fntVersion = lblVersion->font();
fntVersion.setPixelSize(14);
lblVersion->setFont(fntVersion);
lblVersion->setAlignment(Qt::AlignCenter);
lblVersion->setGeometry(0, 0, 200, 30);
lblVersion->move(this->rect().center() - lblVersion->rect().center());
lblVersion->setText(qstrVersion);
lblVersion->setStyleSheet("QLabel {color: white;}");
QString qstrCopy = QString::fromUtf8(
"\u00A9 2014 AlphabetCoinFund Developers\n"
"This is experimental software.\n"
"If you don't treat it as such,\n"
"you're likely to put an eye out.");
QLabel* lblCopy = new QLabel(this);
QFont fntCopy = lblCopy->font();
fntCopy.setPixelSize(12);
lblCopy->setFont(fntCopy);
lblCopy->setAlignment(Qt::AlignCenter);
lblCopy->setGeometry(0, 0, 220, 70);
QPoint pt = this->rect().center() - lblCopy->rect().center();
lblCopy->move(pt.x(), pt.y() + 60);
lblCopy->setText(qstrCopy);
// lblCopy->setStyleSheet("QLabel {color: white; background-color: blue;}");
lblCopy->setStyleSheet("QLabel {color: white;}");
move(QApplication::desktop()->screen()->rect().center() - this->rect().center());
}
示例9: f
Conversation::Conversation(const std::string &contact,
QWidget *parent)
: QWidget(parent), _contact(contact)
{
_call = false;
_first = true;
QLabel *name = new QLabel(tr(contact.c_str()), this);
_textZone = new QLineEdit(this);
_callButton = new QPushButton(this);
_callButton->setIcon(QIcon("./gui/img/phone61.png"));
_callButton->setIconSize(QSize(120, 120));
QPushButton *sendButton = new QPushButton(tr("Send"), this);
_messageZone = new QTextEdit(this);
QFont f("Calibri", 10, QFont::Bold);
name->setFont(f);
_messageZone->setStyleSheet("background-color:white;");
_messageZone->setReadOnly(true);
/* Image */
std::stringstream pp;
pp << "./gui/img/avatar"
<< g_PTUser.currentUser().getContactFromName(contact).getPic()
<< ".png";
QPixmap profilPicture(pp.str().c_str());
QLabel *imgP = new QLabel(this);
imgP->setPixmap(profilPicture.scaled(432, 432, Qt::KeepAspectRatio));
/* --- */
int imgHeight = 432;
int imgWidth = 432;
/* MOVE */
connect(_callButton, SIGNAL(released()), this, SLOT(functionCall()));
connect(sendButton, SIGNAL(released()), this, SLOT(functionText()));
imgP->setGeometry(0, 0, imgHeight, imgWidth);
name->setGeometry(10, imgHeight + 10, 160, 50);
_messageZone->setGeometry(imgWidth, 0, 1370, 920);
_textZone->setGeometry(imgWidth, 920, 1120, 100);
sendButton->setGeometry(1660, 920, 100, 100);
_callButton->setGeometry(130, 900, 120, 120);
/* --- ¨*/
}
示例10: buildGameUi
void MainWindow::buildGameUi()
{
// Create score board
QLabel *scoreBoard = new QLabel();
//scoreBoard->setAttribute(Qt::WA_TranslucentBackground);
scoreBoard->setAlignment(Qt::AlignCenter);
scoreBoard->setText("<font color='white'>SCORE</font>");
QFont *font = new QFont();
font->setPointSizeF(18);
font->setBold(true);
font->setFamily(QString("Adobe Devanagari"));
scoreBoard->setFont(*font);
scoreBoard->setGeometry(QRect(20,20,120,30));
scene->addWidget(scoreBoard);
otherSceneObjectList.push_back(scoreBoard);
// score points
scoreBoardPoints = new QLabel();
scoreBoard->setAttribute(Qt::WA_TranslucentBackground);
scoreBoardPoints->setNum(this->scorePoint);
scoreBoardPoints->setFont(*font);
scoreBoardPoints->setGeometry(QRect(200,20,90,30));
scene->addWidget(scoreBoardPoints);
otherSceneObjectList.push_back(scoreBoardPoints);
// add timer to update
connect(&timer, SIGNAL(timeout()), this,SLOT(updateScorePonit()));
// Create birdleft board
QLabel *birdLeftBoard = new QLabel();
birdLeftBoard->setAttribute(Qt::WA_TranslucentBackground);
birdLeftBoard->setAlignment(Qt::AlignCenter);
birdLeftBoard->setText("<font color='white'>BIRD LEFT</font>");
birdLeftBoard->setFont(*font);
birdLeftBoard->setGeometry(QRect(20,50,150,30));
scene->addWidget(birdLeftBoard);
otherSceneObjectList.push_back(birdLeftBoard);
// bird left num
birdLeftNumbers = new QLabel();
//scoreBoard->setAttribute(Qt::WA_TranslucentBackground);
birdLeftNumbers->setNum(this->scorePoint);
birdLeftNumbers->setFont(*font);
birdLeftNumbers->setGeometry(QRect(200,50,90,30));
scene->addWidget(birdLeftNumbers);
otherSceneObjectList.push_back(birdLeftNumbers);
// add timer to update
connect(&timer, SIGNAL(timeout()), this,SLOT(updateBirdLeft()));
}
示例11: ajoutLecteur
/*** méthode AJOUT LECTEUR ***/
void Ihm::ajoutLecteur(int numLecteur, int num_vue, int x, int y, ClientConnection *cCL){
//se placer sur le bon onglet
QWidget *onglet;
onglet = pDynamique->onglet[num_vue];
//test valeur
//qDebug() << "valeur pointeur onglet" << onglet << endl;
//nouveau label dynamique pour mettre l'image correspondant
QLabel *labelL = new QLabel(onglet);
//différente taille d'images utilisées
if(num_vue == 1){
labelL->setPixmap(QPixmap("ressources/lecteur_actif_petit.jpg"));
}else{
labelL->setPixmap(QPixmap("..//lecteur_actif.jpg"));
}
labelL->setGeometry(x, y, 15, 42); // largeur hauteur à définir
//sauvegarde du pointeur du label du lecteur
//pDynamique->labelL[num_vue][numLecteur] = labelL;
AfficheAlarme *aA = new AfficheAlarme(this, numLecteur);
connect(aA, SIGNAL(signalLecteurInactif(int)), this, SLOT(lecteurInactif(int)));
//en cas de suppression
connect(cCL, SIGNAL(sig_disconnected()), labelL, SLOT(clear()));
connect(cCL, SIGNAL(sig_disconnected()), labelL, SLOT(deleteLater()));
connect(cCL, SIGNAL(sig_disconnected()), aA, SLOT(lecteurInactif()));
}
示例12: icon
Menu::Menu(QWidget *parent) :
QWidget(parent),
ui(new Ui::Menu)
{
ui->setupUi(this);
setWindowFlags(Qt::WindowStaysOnTopHint);
setWindowModality(Qt::ApplicationModal);
setWindowTitle("Tandem Techies");
setFixedSize(geometry().width(), geometry().height());
QIcon icon(":/images/player.png");
setWindowIcon(icon);
QLabel* background = new QLabel(this);
QPixmap backgroundImg(":/images/bg.png");
background->setPixmap(backgroundImg);
background->setGeometry(0, 0, geometry().width(), geometry().height());
background->setScaledContents(true);
background->lower();
background->show();
//Make the logo's background transparent
ui->lblLogo->setAttribute(Qt::WA_TranslucentBackground);
//Make the menu border invisible
setWindowFlags(Qt::MSWindowsFixedSizeDialogHint);
setWindowFlags(Qt::CustomizeWindowHint);
setWindowFlags(Qt::FramelessWindowHint);
}
示例13: loadNewImage
void MainWindow::loadNewImage(QString pathName)
{
if(sa == NULL)
{return;}
FileCentre *fc = FileCentre::GetInstance();
QString path = fc->GetRecordPath();
QDir dir(path);
QStringList filter;
filter<<"*.png"<<"*.jpg"<<"*.bmp";
dir.setNameFilters(filter);
int iNum = dir.count();
if(iNum < 1)
{return;}
//MyLabel *lb = new MyLabel(mLW, pathName);
QLabel *lb = WidgetFactory::GetLabel(mLW, pathName);
lb->setGeometry(QRect(10, (iNum-1)*190, 180, 180));
lb->setPixmap(pathName);
lb->setScaledContents(true);
lb->show();
/*
sa->setWidget(mLW);
sa->setGeometry(0,0, 210, 820);
mLW->setGeometry(0,0,190,190*(iNum+1));
mLW->show();
sa->show();
*/
mLW->setGeometry(0,0,190,190*(iNum+1));
}
示例14: accessories
void accessories(QWidget *baseWidget)
{
QLabel *player2 = new QLabel(baseWidget);
QLabel *name2 = new QLabel("Player 2", baseWidget);
QLabel *time2 = new QLabel("00:00:00", baseWidget);
QLabel *player1 = new QLabel(baseWidget);
QLabel *name1 = new QLabel("Player 1", baseWidget);
QLabel *time1 = new QLabel("00:00:00", baseWidget);
QLabel *moves = new QLabel(baseWidget);
name1->setGeometry(125,610,80,20);
time1->setGeometry(120,635,80,20);
player1->setGeometry(100,500,100,100);
player1->setPixmap(QPixmap(":/Images/profile.png"));
name2->setGeometry(125,210,80,20);
time2->setGeometry(120,235,80,20);
player2->setGeometry(100,100,100,100);
player2->setPixmap(QPixmap(":/Images/profile.png"));
moves->setGeometry(1000,105,250,550);
moves->setStyleSheet("QLabel {background-color: white;}");
}
示例15: imagenFondo
/**
* @brief ventanaIP::ventanaIP
* @param parent
* Constructor que inicializa las parte grafica de la ventana
* e indica los slot apropiados
*/
ventanaIP::ventanaIP(QWidget *parent){
// Instanciamos los objetos de la GUI de la ventana de comandos.
QLabel* fondo = new QLabel(this);
QPixmap imagenFondo("/home/diego/Escritorio/CrazyDuckHunt/ClientePrincipal-ServidorSecundario/FondoPrincipal.jpg");
QPixmap imagenButton("/home/diego/Escritorio/CrazyDuckHunt/ClientePrincipal-ServidorSecundario/buttonSolicitarPeticion.png");
QIcon iconoComandos(imagenButton);
QPushButton* enviarPeticion = new QPushButton(this);
pBarraIP = new QLineEdit("Escriba la IP del servidor", this);
pBarraPuerto = new QLineEdit("Escriba el numero de puerto", this);
// Definimos caracteristicas de los objetos de la GUI
this->resize(imagenFondo.width(),imagenFondo.height());
fondo->setGeometry(0,0,imagenFondo.width(),imagenFondo.height());
fondo->setPixmap(imagenFondo);
pBarraIP->setGeometry(100, 100, 300, 50);
pBarraPuerto->setGeometry(100, 200, 300, 50);
enviarPeticion->setFont(QFont("Times", 18, QFont::Bold));
enviarPeticion->setGeometry(250,270,imagenButton.width(),imagenButton.height());
enviarPeticion->setIcon(iconoComandos);
enviarPeticion->setIconSize(imagenButton.rect().size());
// cout << pBarraIP->text().toStdString() << pBarraPuerto->text().toStdString() <<endl;
QObject::connect(enviarPeticion, SIGNAL(clicked()), this, SLOT(newVentana()));
this->show();
}