⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 04-02.cpp

📁 qt实例代码!《24小时学通qt编程》 的代码!不错!已经在qt2.3.7调试ok!第4章
💻 CPP
字号:
#include <qapplication.h>
#include <qwidget.h>
#include <qpushbutton.h>
#include <qfont.h>
#include <qlineedit.h>
#include <qslider.h>

class MyMainwindow : public QWidget
{
public:
	MyMainwindow();
private:
	QPushButton *b1;
	QPushButton *b2;
	QPushButton *b3;
	QLineEdit *ledit;
};

MyMainwindow::MyMainwindow()
{
	setGeometry(100, 100, 300, 200);

	b1 = new QPushButton("click here to mark the text", this);
	b1->setGeometry(10, 10, 280, 40);
	b1->setFont(QFont("Time", 18, QFont::Bold));

	b2 = new QPushButton("click here to unmark the text", this);
	b2->setGeometry(10, 60, 280, 40);
	b2->setFont(QFont("Time", 18, QFont::Bold));

	b3 = new QPushButton("click here to remove the text", this);
	b3->setGeometry(10, 110, 280, 40);
	b3->setFont(QFont("Time", 18, QFont::Bold));

	ledit = new QLineEdit("This is a line of text", this);
	ledit->setGeometry(10, 160, 280, 30);

	//
	//
	//
	connect(b1, SIGNAL(clicked()), ledit, SLOT(selectAll()));
	connect(b2, SIGNAL(clicked()), ledit, SLOT(deselect()));	
	connect(b3, SIGNAL(clicked()), ledit, SLOT(clear()));
}

int main(int argc, char **argv)
{
	QApplication a(argc,argv);
	MyMainwindow w;
	a.setMainWidget(&w);
	w.show();
	a.exec();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -