窗口的缩放和滚动条的使用
#include<qapplication.h>
#include<qpushbutton.h>
#include<qfont.h>
#include<qscrollview.h>
#include<qmultilineedit.h>
#include<qscrollview.h>
#include<qwidget.h>
#include<qlineedit.h>
#include<qstring.h>
class MyMainWindow: public QScrollView
{
public:
MyMainWindow();
private:
QWidget *main;
QPushButton *b1;
QPushButton *b2;
QPushButton *b3;
QPushButton *b4;
QPushButton *b5;
QMultiLineEdit *edit1;
};
MyMainWindow::MyMainWindow()
{
setGeometry(100,100,470,410);
main =new QWidget(this);
main->resize(460,400);
b1=new QPushButton(“New”, main);
b1->setGeometry(10,10,80,30);
b1->setFont(QFont(“Times”, 18, QFont::Bold));
b2=new QPushButton(“Open”, main);
b2->setGeometry(100, 10, 80, 30);
b2->setFont(QFont(“Times”, 18, QFont::Bold));
b3=new QPushButton(“Save”, main);
b3->setGeometry(190, 10, 80,30);
b3->setFont(QFont(“Times”, 18, QFont::Bold));
b4=new QPushButton(“print”, main);
b4->setGeometry(280, 10, 80, 30);
b4->setFont(QFont(“Times”, 18, QFont::Bold));
b5=new QPushButton(“Exit”, main);
b5->setGeometry(370, 10, 80, 30);
b5->setFont(QFont(“Times”, 18, QFont::Bold));
edit1=new QMultiLineEdit(main);
edit1->setGeometry(0,50,440,340);
edit1->setText(“Let’s pretend this text editor!”);
addChild(main);
connect(b5, SIGNAL(clicked()), qApp, SLOT(quit()));
}
int main(int argc, char **argv)
{
QApplication a(argc, argv);
MyMainWindow w;
a.setMainWidget(&w);
w.show();
return a.exec();
}