#ifndef LINES_H
#define LINES_H
#include <QWidget>
#include <qmainwindow.h>
#include <QMainWindow>
{
Q_OBJECT
public:
Lines();
private:
void createActions();
void updateActions();
void createMenus();
//QMenu *moveMenu;
protected:
};
#endif
#ifndef LINES_H
#define LINES_H
#include <QWidget>
#include <qmainwindow.h>
#include <QMainWindow>
class QMenu;
class QAction;
class QLabel;
class Lines : public QMainWindow
{
Q_OBJECT
public:
Lines();
private:
void createActions();
void updateActions();
void createMenus();
QMenu *fileMenu;
//QMenu *moveMenu;
QAction *exitAct;
protected:
void paintEvent(QPaintEvent *event);
};
#endif
To copy to clipboard, switch view to plain text mode
#include <QtGui>
#include "mainwindow.h"
#include <QApplication>
#include <QPainter>
Lines::Lines()
{
createActions();
createMenus();
setWindowTitle(tr("Tic Tac Toe"));
resize(270, 270);
}
{
QPen pen
(Qt
::black,
2, Qt
::SolidLine);
painter.setPen(pen);
painter.drawLine(93, 20, 93, 250);
painter.drawLine(177, 20, 177, 250);
painter.drawLine(20, 93, 250, 93);
painter.drawLine(20, 177, 250, 177);
//Draw test x
painter.drawLine(30, 30, 80, 80);
painter.drawLine(80, 30, 30, 80);
}
void Lines::createActions()
{
exitAct
= new QAction(tr
("E&xit"),
this);
exitAct->setShortcut(tr("Ctrl+Q"));
connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));
}
void Lines::createMenus()
{
fileMenu
= new QMenu(tr
("&File"),
this);
fileMenu->addAction(exitAct);
}
#include <QtGui>
#include "mainwindow.h"
#include <QApplication>
#include <QPainter>
Lines::Lines()
{
createActions();
createMenus();
setWindowTitle(tr("Tic Tac Toe"));
resize(270, 270);
}
void Lines::paintEvent(QPaintEvent *event)
{
QPen pen(Qt::black, 2, Qt::SolidLine);
QPainter painter(this);
painter.setPen(pen);
painter.drawLine(93, 20, 93, 250);
painter.drawLine(177, 20, 177, 250);
painter.drawLine(20, 93, 250, 93);
painter.drawLine(20, 177, 250, 177);
//Draw test x
painter.drawLine(30, 30, 80, 80);
painter.drawLine(80, 30, 30, 80);
}
void Lines::createActions()
{
exitAct = new QAction(tr("E&xit"), this);
exitAct->setShortcut(tr("Ctrl+Q"));
connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));
}
void Lines::createMenus()
{
fileMenu = new QMenu(tr("&File"), this);
fileMenu->addAction(exitAct);
}
To copy to clipboard, switch view to plain text mode
#include "mainwindow.h"
#include <QDesktopWidget>
#include <QApplication>
int main(int argc, char *argv[])
{
Lines Lines;
Lines.show();
return app.exec();
}
#include "mainwindow.h"
#include <QDesktopWidget>
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
Lines Lines;
Lines.show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks