#include "teste3mainwindow.h"
#include "ui_teste3mainwindow.h"
#include <QGraphicsView>
#include <QGraphicsScene>
#include <QGraphicsTextItem>
#include <QIcon>
#include <QAction>
#include <QWidget>
#include <QMenu>
#include <QMenuBar>
teste3MainWindow
::teste3MainWindow(QWidget *parent
) : ui(new Ui::teste3MainWindow)
{
ui->setupUi(this);
createActions();
createMenus();
createToolBar();
//Cria um QGraphicsScene com um QGraphicView como parent
//ativa a possibilidade de mover o objeto
//Cada objeto tem um tamanho especÃ*fico, devemos descobrir como alterar
//essa propriedade intrÃ*nseca para melhor manipulá-lo
scene->addItem(item);
ui->view->setScene(scene);
ui->view->show();
//Faz com que o view (QGraphicsView) assuma o tamanho da janela. Ela altera
//seu tamanho de acordo com a QMainWindow
teste3MainWindow::setCentralWidget(ui->view);
}
teste3MainWindow::~teste3MainWindow()
{
delete ui;
}
//slots
void teste3MainWindow::newFile()
{
scene->addItem((item));
ui->view->setScene(scene);
}
//private functions
void teste3MainWindow::createActions()
{
newAction
= new QAction(tr
("&New"),
this);
//newAction->setIcon(QIcon(":/images/circulo.png"));
newAction->setStatusTip(tr("omg!!"));
connect(newAction,SIGNAL(triggered()),this,SLOT(newFile()));
newAction2
= new QAction(tr
("&New"),
this);
//newAction2->setShortcut(QKeySequence::New);
newAction2->setStatusTip(tr("omg!!"));
connect(newAction2,SIGNAL(triggered()),this,SLOT(newFile()));
}
void teste3MainWindow::createMenus()
{
fileMenu = menuBar()->addMenu("&File");
fileMenu->addAction(newAction);
fileMenu->addSeparator();
fileMenu->addAction(newAction2);
editMenu = menuBar()->addMenu(tr("&Edit"));
}
void teste3MainWindow::createToolBar()
{
ui->toolBar->addAction(newAction);
ui->toolBar->addSeparator();
ui->toolBar->addAction(newAction2);
}
#include "teste3mainwindow.h"
#include "ui_teste3mainwindow.h"
#include <QGraphicsView>
#include <QGraphicsScene>
#include <QGraphicsTextItem>
#include <QIcon>
#include <QAction>
#include <QWidget>
#include <QMenu>
#include <QMenuBar>
teste3MainWindow::teste3MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::teste3MainWindow)
{
ui->setupUi(this);
createActions();
createMenus();
createToolBar();
//Cria um QGraphicsScene com um QGraphicView como parent
QGraphicsScene *scene = new QGraphicsScene(ui->view);
QGraphicsTextItem *item = new QGraphicsTextItem("MaDog");
//ativa a possibilidade de mover o objeto
//Cada objeto tem um tamanho especÃ*fico, devemos descobrir como alterar
//essa propriedade intrÃ*nseca para melhor manipulá-lo
item->setFlag(QGraphicsItem::ItemIsMovable,true);
scene->addItem(item);
ui->view->setScene(scene);
ui->view->show();
//Faz com que o view (QGraphicsView) assuma o tamanho da janela. Ela altera
//seu tamanho de acordo com a QMainWindow
teste3MainWindow::setCentralWidget(ui->view);
}
teste3MainWindow::~teste3MainWindow()
{
delete ui;
}
//slots
void teste3MainWindow::newFile()
{
scene = new QGraphicsScene(this);
QGraphicsTextItem *item = new QGraphicsTextItem("NewFile");
scene->addItem((item));
ui->view->setScene(scene);
}
//private functions
void teste3MainWindow::createActions()
{
newAction = new QAction(tr("&New"),this);
newAction->setShortcut(QKeySequence::New);
//newAction->setIcon(QIcon(":/images/circulo.png"));
newAction->setStatusTip(tr("omg!!"));
connect(newAction,SIGNAL(triggered()),this,SLOT(newFile()));
newAction2 = new QAction(tr("&New"),this);
//newAction2->setShortcut(QKeySequence::New);
newAction2->setStatusTip(tr("omg!!"));
connect(newAction2,SIGNAL(triggered()),this,SLOT(newFile()));
}
void teste3MainWindow::createMenus()
{
fileMenu = menuBar()->addMenu("&File");
fileMenu->addAction(newAction);
fileMenu->addSeparator();
fileMenu->addAction(newAction2);
editMenu = menuBar()->addMenu(tr("&Edit"));
}
void teste3MainWindow::createToolBar()
{
ui->toolBar->addAction(newAction);
ui->toolBar->addSeparator();
ui->toolBar->addAction(newAction2);
}
To copy to clipboard, switch view to plain text mode
Bookmarks