QT中QToolBox的使用,实现抽屉效果

更新时间:2023-06-26 21:53:16 阅读: 评论:0

QT中QToolBox的使⽤,实现抽屉效果drawer.h
#ifndef DRAWER_H
#define DRAWER_H
#include <QtGui>
#include "ui_drawer.h"
class drawer : public QToolBox
{
Q_OBJECT
public:
drawer( QWidget *parent=0, Qt::WindowFlags  f=0 );
~drawer();
QToolButton *toolButton1_1;
QToolButton *toolButton1_2;
QToolButton *toolButton1_3;
QToolButton *toolButton1_4;
QToolButton *toolButton1_5;
QToolButton *toolButton2_1;
QToolButton *toolButton2_2;
QToolButton *toolButton3_1;
QToolButton *toolButton3_2;
private:
Ui::drawerClass ui;
};
#endif // DRAWER_H
drawer.cpp
#include "drawer.h"
drawer::drawer( QWidget *parent, Qt::WindowFlags  f )
: QToolBox( parent, f )
{
南红玛瑙手串
tWindowTitle(tr("My QQ"));
QGroupBox *groupBox1 = new QGroupBox();
toolButton1_1 = new QToolButton( );
toolButton1_1->tText( tr( "beibei" ) );
陪我走下去
toolButton1_1->tIcon( QPixmap(":/images/bb.png") );
toolButton1_1->tIconSize( QPixmap(":/images/bb.png").size() );
toolButton1_1->tAutoRai( TRUE );
toolButton1_1->tToolButtonStyle( Qt::ToolButtonTextBesideIcon);
// toolButton1_1->tToolButtonStyle( Qt::ToolButtonTextUnderIcon);
toolButton1_2 = new QToolButton();
toolButton1_2->tText( tr( "jingjing" ) );
普者黑主要3个景点
toolButton1_2->tIcon( QPixmap( ":/images/jj.png") );
toolButton1_2->tIconSize( QPixmap( ":/images/jj.png").size() );
toolButton1_2->tAutoRai( TRUE );
toolButton1_2->tToolButtonStyle( Qt::ToolButtonTextUnderIcon);
toolButton1_3 = new QToolButton();
toolButton1_3->tText( tr( "huanhuan" ) );
toolButton1_3->tIcon( QPixmap( ":/images/hh.png") );
toolButton1_3->tIconSize( QPixmap( ":/images/hh.png").size() );
toolButton1_3->tAutoRai( TRUE );
toolButton1_3->tToolButtonStyle( Qt::ToolButtonTextUnderIcon);
toolButton1_4 = new QToolButton();
toolButton1_4->tText( tr( "yingying" ) );
toolButton1_4->tIcon( QPixmap( ":/images/yy.png") );
toolButton1_4->tIconSize( QPixmap( ":/images/yy.png").size() );
toolButton1_4->tAutoRai( TRUE );
toolButton1_4->tToolButtonStyle( Qt::ToolButtonTextUnderIcon);
toolButton1_5 = new QToolButton();
toolButton1_5->tText( tr( "nini" ) );
toolButton1_5->tIcon( QPixmap( ":/images/nn.png") );麻辣鱼头的做法
toolButton1_5->tIconSize( QPixmap( ":/images/nn.png").size() );
toolButton1_5->tAutoRai( TRUE );
toolButton1_5->tToolButtonStyle( Qt::ToolButtonTextUnderIcon);
QVBoxLayout *layout1 = new QVBoxLayout(groupBox1);
layout1->tMargin(10);
layout1->tAlignment(Qt::AlignHCenter);
写信作文300字layout1->addWidget(toolButton1_1);
layout1->addWidget(toolButton1_2);
layout1->addWidget(toolButton1_3);
layout1->addWidget(toolButton1_4);
layout1->addWidget(toolButton1_5);
layout1->addStretch();
QGroupBox *groupBox2 = new QGroupBox();
toolButton2_1 = new QToolButton( );
toolButton2_1->tText( tr( "pizicai" ) );
toolButton2_1->tIcon( QPixmap( ":/images/1.png" ) );
toolButton2_1->tIconSize( QPixmap( ":/images/1.png").size() ); toolButton2_1->tAutoRai( TRUE );
toolButton2_1->tToolButtonStyle( Qt::ToolButtonTextUnderIcon); toolButton2_2 = new QToolButton();
toolButton2_2->tText( tr( "feiyang" ) );
toolButton2_2->tIcon( QPixmap( ":/images/2.png") );
toolButton2_2->tIconSize( QPixmap( ":/images/2.png").size() ); toolButton2_2->tAutoRai( TRUE );
toolButton2_2->tToolButtonStyle( Qt::ToolButtonTextUnderIcon); QVBoxLayout *layout2 = new QVBoxLayout(groupBox2);
layout2->tMargin(10);
layout2->tAlignment(Qt::AlignHCenter);
layout2->addWidget(toolButton2_1);
秋天文章layout2->addWidget(toolButton2_2);
layout2->addStretch();
QGroupBox *groupBox3 = new QGroupBox();
toolButton3_1 = new QToolButton( );
toolButton3_1->tText( tr( "QQ" ) );
toolButton3_1->tIcon( QPixmap( ":/images/3.png" ) );
toolButton3_1->tIconSize( QPixmap( ":/images/3.png").size() ); toolButton3_1->tAutoRai( TRUE );老师评价学生评语
toolButton3_1->tToolButtonStyle( Qt::ToolButtonTextUnderIcon); toolButton3_2 = new QToolButton();
toolButton3_2->tText( tr( "angel" ) );
toolButton3_2->tIcon( QPixmap( ":/images/4.png") );
toolButton3_2->tIconSize( QPixmap( ":/images/4.png").size() ); toolButton3_2->tAutoRai( TR
UE );
toolButton3_2->tToolButtonStyle( Qt::ToolButtonTextUnderIcon); QVBoxLayout *layout3 = new QVBoxLayout(groupBox3);
layout3->tMargin(10);
layout3->tAlignment(Qt::AlignHCenter);
layout3->addWidget(toolButton3_1);
layout3->addWidget(toolButton3_2);
layout3->addStretch();
this->addItem( ( QWidget* )groupBox1 , tr("my friends" ));
this->addItem( ( QWidget* )groupBox2 , tr("stranger" ));
this->addItem( ( QWidget* )groupBox3 , tr("blacklist" ));
}
drawer::~drawer()
{
}
main.cpp
#include "drawer.h"
#include <QtGui/QApplication>
int main(int argc, char *argv[])
文艺年华{
QApplication a(argc, argv);
drawer *w=new drawer;
w->show();
();
}
项⽬⽂件组织结构为:
图⽚⼤家可以⾃⼰找⼀些。资源⽂件drawer.qrc内容为:
下⾯贴出效果:

本文发布于:2023-06-26 21:53:16,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/89/1056288.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:效果   评价   红玛瑙   鱼头
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图