本文整理汇总了C++中QLabel::setLayout方法的典型用法代码示例。如果您正苦于以下问题:C++ QLabel::setLayout方法的具体用法?C++ QLabel::setLayout怎么用?C++ QLabel::setLayout使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QLabel
的用法示例。
在下文中一共展示了QLabel::setLayout方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initializeWidget
void MorePage::initializeWidget()
{
//导航栏
QString strTitle = tr("更多...");
navigationBar = new NavigationBar(this);
navigationBar->setTitleText(strTitle);
QHBoxLayout* pHLTop = new QHBoxLayout();
pHLTop->addWidget(navigationBar);
pHLTop->setSpacing(0);
pHLTop->setMargin(0);
this->setTopbarLayout(pHLTop);
//个人信息
QLabel* themeWidget = new QLabel;
QPixmap pixmap = QPixmap(ImagePath::MOREPAGE_THEME);
pixmap.setDevicePixelRatio(2);
themeWidget->setAutoFillBackground(true);
themeWidget->setFixedHeight(this->screenHeight()*0.25);
themeWidget->setFixedWidth(this->screenWidth());
themeWidget->setPixmap(pixmap);
themeWidget->setScaledContents(true);
btnPersonalInfo = new QToolButton;
btnPersonalInfo->setFixedWidth(this->screenWidth());
btnPersonalInfo->setFixedHeight(this->screenHeight()*0.15);
btnPersonalInfo->setIconSize(QSize(btnPersonalInfo->height()*0.7, btnPersonalInfo->height()*0.7));
btnPersonalInfo->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
btnPersonalInfo->setStyleSheet("font:16px; color:white;background-color:rgba(0,0,0,0)");
connect(btnPersonalInfo, SIGNAL(clicked()), SLOT(on_btnPersonal_clicked()));
QVBoxLayout* themeLayout = new QVBoxLayout;
themeLayout->addWidget(btnPersonalInfo);
themeLayout->setMargin(0);
themeWidget->setLayout(themeLayout);
//设置
btnSetting = new GroupButton;
btnSetting->setStyleSheet(SheetStyle::GROUPBUTTON_BOTTOMBORDER);
QPixmap settingPixmap(ImagePath::SETTING);
this->setGroupButton(btnSetting, settingPixmap, tr("设置"));
connect(btnSetting, SIGNAL(clicked()), SLOT(on_btnSetting_clicked()));
QVBoxLayout* vblTotalLayout = new QVBoxLayout;
vblTotalLayout->addWidget(themeWidget);
vblTotalLayout->addSpacing(this->screenHeight()*0.026);
vblTotalLayout->addWidget(btnSetting);
vblTotalLayout->setAlignment(Qt::AlignTop);
vblTotalLayout->setMargin(0);
vblTotalLayout->setSpacing(0);
this->setBodyPartLayout(vblTotalLayout);
//屏幕触摸滚动设置
this->setBodyScreenHeight(this->scrollAreaHasBottomBarHeight());
this->installScrollViewportArea();
this->loadLocalData(curAccountID);
}
示例2: 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);
}
示例3: addMsg
void CChatWidget::addMsg(const QString& vMsg, const QString& vSenderName, EMsgSendRecv vSendRecv)
{
QLabel* pMsgItem = new QLabel(m_pRecordWidget);
QGridLayout* pMsgLayout = new QGridLayout(pMsgItem);
pMsgItem->setLayout(pMsgLayout);
QString strTime = QTime::currentTime().toString("HH:mm:ss");
Qt::Alignment align = (vSendRecv == eSend) ? Qt::AlignRight : Qt::AlignLeft;
pMsgLayout->addWidget(new QLabel(strTime, pMsgItem), 0, 0, 1, 10, align);
pMsgLayout->addWidget(new QLabel(vMsg, pMsgItem), 1, 0, 1, 8, align);
pMsgLayout->addWidget(new QLabel(vSenderName, pMsgItem), 1, 9, 1, 1, align);
pMsgItem->setFixedHeight(60);
m_pRecordWidget->setFixedHeight(m_pRecordWidget->height() + pMsgItem->height());
m_pRecordWidget->layout()->addWidget(pMsgItem);
m_psbRecord->setMaximumHeight(this->height());
m_psbRecord->setSliderPosition(m_psbRecord->maximum());
}
示例4: main
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QLabel ww;
ww.setPixmap(QPixmap("qt-logo.png"));
//qDebug("wid=%d", (int)ww.winId());
QVBoxLayout vl;
ww.setLayout(&vl);
QAeroWidget aero_widget;
//w.setWindowFlags(Qt::Window | Qt::WindowStaysOnTopHint);
aero_widget.setEffect(QAeroWidget::Aero);
aero_widget.setEffectOpacity(0.1);
QLabel text(&aero_widget);
text.setText("<font color=#ff0000 size=22>Aero Widget</font>");
QAeroWidget blur_widget;
blur_widget.setEffect(QAeroWidget::Blur);
blur_widget.setEffectOpacity(0.1);
QLabel bl(&blur_widget);
bl.setText("<font color=#ff00ff size=22>Blur Widget</font>");
QAeroWidget st_widget;
st_widget.setEffect(QAeroWidget::SemiTransparent);
st_widget.setEffectOpacity(0.1);
QLabel stl(&st_widget);
stl.setText("<font color=#ffff00 size=22>SemiTransparent Widget</font>");
QLabel normal_text;
normal_text.setText("<font color=#0000ff size=22>Normal Widget</font>");
vl.addWidget(&aero_widget);
vl.addWidget(&blur_widget);
vl.addWidget(&st_widget);
vl.addWidget(&normal_text);
ww.show();
QAeroWidget aero_window;
aero_window.setEffect(QAeroWidget::Aero);
//aero_window.setEffectOpacity(0.618);
//aero_window.setWindowFlags(Qt::FramelessWindowHint);
QLabel text_aw(&aero_window);
text_aw.setText("<font color=#ff0000 size=22>Aero Window</font>");
aero_window.show();
aero_window.resize(text_aw.size());
QAeroWidget blur_window;
blur_window.setEffect(QAeroWidget::Blur);
QLabel text_awbb(&blur_window);
text_awbb.setText("<font color=#ff0000 size=22>Blur Window</font>");
blur_window.show();
blur_window.resize(text_awbb.size());
QAeroWidget semitransparent_window;
semitransparent_window.setEffect(QAeroWidget::SemiTransparent);
semitransparent_window.setEffectOpacity(0.618);
QLabel text_semitransparent_window(&semitransparent_window);
text_semitransparent_window.setText("<font color=#ff0000 size=22>SemiTransparent Window</font>");
semitransparent_window.show();
semitransparent_window.resize(text_semitransparent_window.size());
return a.exec();
}
示例5: main
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QPalette p;
p.setColor(QPalette::Background, QColor("#97CBFF"));
a.setPalette(p);
//a.setAutoFillBackground(true);
QLabel *window = new QLabel();
window->setWindowTitle(TEXT_WINDOW_TITLE);
QLabel *horCoordinate = new QLabel();
QPixmap hCoord(PATH_HCOORD_IMG);
horCoordinate->setPixmap(hCoord);
horCoordinate->setMinimumSize(SIZE_COORDINATE_L, SIZE_COORDINATE_W);
QLabel *verCoordinate = new QLabel();
QPixmap vCoord(PATH_VCOORD_IMG);
verCoordinate->setPixmap(vCoord);
verCoordinate->setMinimumSize(SIZE_COORDINATE_W, SIZE_COORDINATE_L);
Chessboard *chessboard = new Chessboard();
QPixmap img(PATH_CHESSBORAD_IMG);
chessboard->setPixmap(img.scaled(SIZE_CHESSBOARD, SIZE_CHESSBOARD));
chessboard->setMinimumSize(SIZE_CHESSBOARD, SIZE_CHESSBOARD);
QTextCodec *TradChineseCodec = QTextCodec::codecForName("Big5-ETen");
QLabel *chessboardReadme = new QLabel(TradChineseCodec->toUnicode(
"<center> <b>黑方</b> 滑鼠左鍵 |<b> 白方</b> 滑鼠右鍵 |<b> 清空</b> 滑鼠中鍵 </center>"));
chessboardReadme->setAlignment(Qt::AlignHCenter);
QLabel *funcReadme = new QLabel(TradChineseCodec->toUnicode(" <br> <br> <br> <br> <br><br> <br> <br> <br>"));
QPushButton *clearBoard = new QPushButton(TradChineseCodec->toUnicode("清空棋盤"));
QObject::connect(clearBoard, SIGNAL(clicked()), chessboard, SLOT(cleanChessboard()));
QPushButton *readBoardData = new QPushButton(TradChineseCodec->toUnicode("讀取已存棋盤"));
QObject::connect(readBoardData, SIGNAL(clicked()), chessboard, SLOT(readFromTxt()));
QGridLayout *buttonLayout = new QGridLayout();
buttonLayout->addWidget(readBoardData, 0, 0);
buttonLayout->addWidget(clearBoard, 0, 1);
QGridLayout *wholeChessboard = new QGridLayout;
wholeChessboard->addWidget(horCoordinate, 0, 1);
wholeChessboard->addWidget(verCoordinate, 1, 0);
wholeChessboard->addWidget(chessboard, 1, 1);
wholeChessboard->addWidget(chessboardReadme, 2, 0, 1, 2);
wholeChessboard->addLayout(buttonLayout, 3, 0, 1, 2);
wholeChessboard->addWidget(funcReadme, 4, 0, 1, 2);
wholeChessboard->setMargin(20);
FuncSet1 *findThreat = new FuncSet1();
findThreat->setMinimumSize(SIZE_FUNC_W, SIZE_FUNC_H2);
findThreat->setBrd(&(chessboard->boardData));
FuncSet2 *threatSpaceSearch = new FuncSet2();
threatSpaceSearch->setMinimumSize(SIZE_FUNC_W, SIZE_FUNC_H1);
threatSpaceSearch->setBrd(&(chessboard->boardData));
FuncSet3 *availableMove = new FuncSet3();
availableMove->setMinimumSize(SIZE_FUNC_W, SIZE_FUNC_H2);
availableMove->setBrd(&(chessboard->boardData));
FuncSet4 *proofNumberSearch = new FuncSet4();
proofNumberSearch->setMinimumSize(SIZE_FUNC_W, SIZE_FUNC_H1);
proofNumberSearch->setBrd(&(chessboard->boardData));
QGridLayout *wholeApp = new QGridLayout();
wholeApp->addLayout(wholeChessboard, 0, 0, 3, 1);
wholeApp->addWidget(availableMove, 0, 1);
wholeApp->addWidget(findThreat, 1, 1);
wholeApp->addWidget(threatSpaceSearch, 2, 1);
wholeApp->addWidget(proofNumberSearch, 0, 2, 3, 1);
wholeApp->setSpacing(15);
QObject::connect(chessboard, SIGNAL(changeFuncsTurn(int)), availableMove, SLOT(changeTurn(int)));
QObject::connect(chessboard, SIGNAL(changeFuncsTurn(int)), findThreat, SLOT(changeTurn(int)));
QObject::connect(chessboard, SIGNAL(changeFuncsTurn(int)), threatSpaceSearch, SLOT(changeTurn(int)));
QObject::connect(chessboard, SIGNAL(changeFuncsTurn(int)), proofNumberSearch, SLOT(changeTurn(int)));
//wholeChessboard->addWidget(test, 4, 0, 1, 2);
/*Paper *ya = new Paper();
wholeApp->addWidget(ya, 2,2);
BoardData orig;
orig.printBoard(ya);
orig.set(0,0,BLACK);
orig.set(0,1,WHITE);
orig.printBoard(ya);
BoardData *tmp = new BoardData(&orig);
tmp->set(1,1,BLACK);
tmp->printBoard(ya);
orig.printBoard(ya);*/
window->setLayout(wholeApp);
// 把其他method也寫進去
//.........这里部分代码省略.........