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

📄 main.cpp

📁 qt类库是非微软类库
💻 CPP
字号:
#include <qapplication.h>
#include <qwidget.h>
#include <qpushbutton.h>
#include <qfont.h>
#include <qlcdnum.h>
#include <qslider.h>

class MyMainWindow : public QWidget
{
	public:
		MyMainWindow();
	private:
		QPushButton *b1;
	    QLCDNumber  *lcd;
		QSlider     *slider;

};
MyMainWindow::MyMainWindow()
{
	setGeometry(100,100,300,200);
    b1=new QPushButton("EXIT",this);
	b1->setGeometry(10,10,80,40);
	b1->setFont(QFont("Times",18,QFont::Bold));
	connect(b1,SIGNAL(clicked()),qApp,SLOT(quit()));

	lcd=new QLCDNumber(2,this);
	lcd->setGeometry(100,10,190,180);

	slider=new QSlider(Vertical,this);
	slider->setGeometry(10,60,80,130);

	connect(slider,SIGNAL(valueChanged(int)),lcd,SLOT(display(int)));

}
int main(int argc,char** argv)
{
  QApplication a(argc,argv);
  MyMainWindow mainwindow;
  mainwindow.setMinimumSize(200,100);
  mainwindow.setMaximumSize(400,300);
  //QPushButton helloworld("Hello!Mr Li!",&mainwindow);
  //helloworld.setGeometry(20,20,60,70);

  //QPushButton helloworld1("汉",&mainwindow);
  //helloworld1.setGeometry(90,20,60,70);

  a.setMainWidget(&mainwindow);
  mainwindow.show();
  return a.exec();
}

⌨️ 快捷键说明

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