#include <QtGui>
#include "filemainwindow.h"
FileMainWindow::FileMainWindow() //继承QMainWindow
{
createActions() ; / /
createMenus(); //
createToolBars();
setMaximumSize ( 800, 800 );
setMinimumSize ( 800, 800 );
setWindowIcon(QIcon(":/images/icon.png"));
area1 = new PaintArea; // 用
area2 = new PaintArea;
QGridLayout *layout = new QGridLayout;
layout->addWidget(area1,0,0);
layout->addWidget(area2,0,1);
setLayout(layout); / /这里用setLayout没有显示。
}
PaintArea 的定义代码.用来画图形的
class PaintArea : public QWidget
{
Q_OBJECT
public:
PaintArea(QWidget *parent=0);
void setFillRule(int);
void setPenWidth(int);
void setPenColor(QColor);
void setBrushColor(QColor);
void paintEvent(QPaintEvent *);
private:
Qt::FillRule rule;
int width;
QColor penColor;
QColor brushColor;
};
我在FileMainWindow里显示两幅画出来的图形。不管我用QGridLayout或者QVBoxLayout 都不行。
为什么用setLayout(layout); 不能显示出来,而如何只是用setCentralWidget(area1).就能显示出一副图形? 请指点。