当前位置:网站首页>Qpushbutton- "function refinement"
Qpushbutton- "function refinement"
2022-07-07 02:37:00 【Red guest white hat】
QPushButton
- Section 1 QT brief introduction
- In the second quarter QPushButton
- One 、 Constructors
- Two 、Geometry
- Four 、setFont
- 5、 ... and 、text
- 6、 ... and 、setText
- 7、 ... and 、move
- 8、 ... and 、resize
- Nine 、adjustSize
- Ten 、setFocus
- 11、 ... and 、hasFocus
- Twelve 、clearFocus
- 13、 ... and 、setCursor
- fourteen 、setDisabled
- sixteen 、setVisible
- seventeen 、setFlat
- eighteen 、isFlat
- nineteen 、setDefault
- twenty 、QIcon
- The 21st 、setIcon
- Twenty-two 、setIconSize
- 23 、setStyleSheet
- Twenty-four 、X
- twenty-five 、y
- hexacosa- 、QPoint
- twenty-seven 、pos
- Twenty-eight 、width
- Twenty-nine 、height
- thirty 、QSize
- Thirty-one 、QRect
- Thirty-two 、setFixedSize
- Thirty-three 、Css Style sheets
- Thirty-four 、Qss sentence
Section 1 QT brief introduction
250 More than C++ class
Installation requires setting environment variables (path)
【 add to Tools Inside bin And compiling 32/64 The one in the seat bin】
In the second quarter QPushButton
One 、 Constructors
QPushButton(const QString &text, QWidget *parent = nullptr)
Parameters :text --》 The literal information of the button
parent --》 The parent window of the button
QPushButton bt =new QPushButton;// Independent window ;
QPushButton bt =new QPushButton(this);// Embedded in this Point to the window ;
Two 、Geometry
geometry: Positioning coordinates , Length, width, size ;
geometry --》 Function name setGeometry() ;
3、 ... and 、 QFont
font --》 Set the font
font --》 Function name setFont()
Four 、setFont
ui->pushButton->setFont(QFont(" Song style ", 15));
5、 ... and 、text
Get the text information on the button
QString content = ui->pushButton->text();
qDebug() << content.toUtf8().data(); // QString Type transfer char* type , Solve the problem of printing Chinese garbled code
6、 ... and 、setText
Set the text information on the button
ui->pushButton->setText(" Button ");
7、 ... and 、move
Reset the position of the button
ui->pushButton->move(100, 50);
8、 ... and 、resize
Reset the size of the button
ui->pushButton->resize(80, 50);// Wide and high
Nine 、adjustSize
ui->pushButton->setText(" I am a long, long, long text ");
Automatically resize the control , To suit its content ;
ui->pushButton->adjustSize();
Ten 、setFocus
Set the control to get focus
ui->pushButton->setFocus();
11、 ... and 、hasFocus
Gets whether the control has focus ; If the control has focus , return true;
bool b = ui->pushButton->hasFocus();
qDebug() << b;
Twelve 、clearFocus
Clear the focus of the control
ui->pushButton->clearFocus();
13、 ... and 、setCursor
Set when the mouse is in the button control area , The type of cursor
ui->pushButton->setCursor(QCursor(Qt::BusyCursor));
fourteen 、setDisabled
Disable control
ui->pushButton->setDisabled(true);
15、 ... and 、setEnabled
Enable controls
ui->pushButton->setEnabled(true);
sixteen 、setVisible
Hide controls
ui->pushButton->setVisible(false);
Display controls
ui->pushButton->setVisible(true);
seventeen 、setFlat
Set the control background transparent : Set the appearance of the control to tile
ui->pushButton->setFlat(true);
eighteen 、isFlat
QPushButton *btn = new QPushButton(this); // Create a button in the current interface
btn->setText(" I am not flat "); // The Settings button displays text
btn->setGeometry(150, 100, 100, 50);// Set the display position
btn->setFlat(true);// Set the button to be flat
if (btn->isFlat())// Judge whether it is flat
{
btn->setText(" I am flat ");
}
nineteen 、setDefault
Set press... On the control Enter key when , Respond to the control's click event
ui->pushButton->setDefault(true);
twenty 、QIcon
Set the image path
QIcon(":/Image/Luffy.png")
The 21st 、setIcon
Set the icon displayed on the button
ui->pushButton->setIcon(QIcon(":/Image/Luffy.png"));
Twenty-two 、setIconSize
Sets the size of the icon
ui->pushButton->setIconSize(QSize(24, 24));
23 、setStyleSheet
button1.setStyleSheet("
QPushButton{
font-family:' Song style ';font-size:32px;color:rgb(0,0,0,255);}\
QPushButton{
background-color:rgb(170,200,50)}\ QPushButton:hover{
background-color:rgb(50, 170, 200)}")
Twenty-four 、X
Returns the x coordinate
int x = x()
twenty-five 、y
QPushButton* btn=new QPushButton(" Button ",this);
btn->move(15,10);
x=btn->x(); // Returns the x coordinate
y=btn->y(); // Returns the y coordinate
hexacosa- 、QPoint
QPoint point;
twenty-seven 、pos
point=btn->pos(); // Returns the coordinates of the control --QPoint(15,10)
i=point.x();// extract x coordinate
i=point.y();// extract y coordinate
Twenty-eight 、width
i=btn->width(); // Width of control , Does not contain any window frames
Twenty-nine 、height
i=btn->height(); // Height of control , Does not contain any window frames
thirty 、QSize
QSize size;
size=btn->size(); // Returns the width and height of the control ;width and height The combination of QSize(100, 30);
i=size.width(); // Extraction width
i=size.height();// Extraction height
Thirty-one 、QRect
QRect rect;
rect=btn->geometry(); // The combination of position and size relative to the parent control QRect(15,10 100x30);
i=rect.x(); // extract x coordinate
i=rect.y(); // extract y coordinate
size=rect.size();// Extract size -- Width and height
i=rect.width(); // Extraction width
i=rect.height(); // Extraction high
Thirty-two 、setFixedSize
setFixedSize(500,400); // Set fixed size ( Width and height )
Thirty-three 、Css Style sheets
QPushButton{
background-color: #2786ba;/* The background color */
border-radius:5px;/* Button border fillet settings */
/* Button background icon settings */
background-image: url(:/configIcon.png); /* Background image */
background-origin: content;
background-position: center;/* The location of the background image */
padding-right: 40px; /* Background icon padding Parameters */
padding-bottom: 2px;/* Background icon padding Parameters */
background-repeat: no-repeat; /* Set the tiling mode of the background image */
/* Button text settings */
text-align: top; /* Alignment position of text */
padding-left: 2px;/* Textual padding Parameters */
padding-top: 2px;
font-size: 12px;// font size
color: #FFFFFF; /* text color */
}
Thirty-four 、Qss sentence
【1】QPushButton:pressed{
Set the background picture when the button is pressed Style design for the main window
background-image: url(:/button_down.png);
}
【2】QPushButton:pressed#regBt{
Set the specified button regBt The background picture when the button is pressed Style design for the main window
background-image: url(:/button_down.png);
}
【3】QPushButton:hover{
Style design for the main window
background-color:#ff00ff; Setting the background color of the mouse entry control
}
《QT The omnipotent Chinese manual is being updated 》
边栏推荐
- Processus général de requête pour PostgreSQL
- Lombok makes the pit of ⽤ @data and @builder at the same time
- Application analysis of face recognition
- 3D laser slam: time synchronization of livox lidar hardware
- 如何从0到1构建32Core树莓派集群
- 普通测试年薪15w,测试开发年薪30w+,二者差距在哪?
- Cloud Mail .NET Edition
- [node learning notes] the chokidar module realizes file monitoring
- MySQL
- 4--新唐nuc980 挂载initramfs nfs文件系统
猜你喜欢
postgresql之整體查詢大致過程
一文读懂Faster RCNN
FLIR blackfly s usb3 industrial camera: how to use counters and timers
Processus général de requête pour PostgreSQL
Detailed explanation of line segment tree (including tested code implementation)
Lombok makes the pit of ⽤ @data and @builder at the same time
运维管理系统有哪些特色
Fundamentals of process management
普通测试年薪15w,测试开发年薪30w+,二者差距在哪?
Use of fiddler
随机推荐
哈希表及完整注释
1个月增长900w+播放!总结B站顶流恰饭的2个新趋势
postgresql之整體查詢大致過程
dotConnect for DB2数据提供者
Station B's June ranking list - feigua data up main growth ranking list (BiliBili platform) is released!
【软件测试】最全面试问题和回答,全文背熟不拿下offer算我输
C#/VB.NET 删除Word文档中的水印
Lombok同时使⽤@Data和@Builder 的坑
The panel floating with the mouse in unity can adapt to the size of text content
安全交付工程师
How to build a 32core raspberry pie cluster from 0 to 1
Douban average 9 x. Five God books in the distributed field!
Fundamentals of process management
Difference and the difference between array and array structure and linked list
Stm32f4 --- PWM output
[paper reading | deep reading] anrl: attributed network representation learning via deep neural networks
Google Earth Engine(GEE)——Landsat 全球土地调查 1975年数据集
PCL 常用拟合模型及使用方法
CDB PDB user rights management
Leetcode:minimum_depth_of_binary_tree解决问题的方法