#ifndef DESENHO_H
#define DESENHO_H
#include <QWidget>
#include <QVBoxLayout>
#include <QSpacerItem>
#include <QPushButton>
{
Q_OBJECT
public:
~Widget();
protected:
private:
};
#endif
#ifndef DESENHO_H
#define DESENHO_H
#include <QWidget>
#include <QVBoxLayout>
#include <QSpacerItem>
#include <QPushButton>
class Widget : public QWidget
{
Q_OBJECT
public:
Widget(QWidget *parent = 0);
~Widget();
void draw(QPainter *painter);
protected:
void paintEvent(QPaintEvent *event);
private:
QPushButton *btn1, *btn2;
QSpacerItem *spacer;
QVBoxLayout *verticalLayout;
QHBoxLayout *horizontalLayout;
};
#endif
To copy to clipboard, switch view to plain text mode
#include <QtGui>
#include "widget.h"
{
verticalLayout->addStretch(1);
// horizontalLayout->addItem(spacer);
horizontalLayout->addWidget(btn1);
horizontalLayout->addWidget(btn2);
verticalLayout->addLayout(horizontalLayout);
this->setLayout(verticalLayout);
//verticalLayout->addItem(spacer);
//verticalLayout->addWidget(btn1);
//verticalLayout->addWidget(btn2);
}
Widget::~Widget()
{
}
{
painter.
setRenderHint(QPainter::Antialiasing,
true);
draw(&painter);
}
{
}
#include <QtGui>
#include "widget.h"
Widget::Widget(QWidget *parent)
: QWidget(parent)
{
btn1 = new QPushButton(this);
btn2 = new QPushButton(this);
spacer = new QSpacerItem(0,100);
verticalLayout = new QVBoxLayout(this);
horizontalLayout=new QHBoxLayout;
verticalLayout->addStretch(1);
// horizontalLayout->addItem(spacer);
horizontalLayout->addWidget(btn1);
horizontalLayout->addWidget(btn2);
verticalLayout->addLayout(horizontalLayout);
this->setLayout(verticalLayout);
//verticalLayout->addItem(spacer);
//verticalLayout->addWidget(btn1);
//verticalLayout->addWidget(btn2);
}
Widget::~Widget()
{
}
void Widget::paintEvent(QPaintEvent * /* event */)
{
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing, true);
draw(&painter);
}
void Widget::draw(QPainter *painter)
{
}
To copy to clipboard, switch view to plain text mode
Bookmarks