⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mainwindow.cpp

📁 本文件是<精通QT4编程>的配套源代码
💻 CPP
字号:
#include "mainwindow.h"
#include "target.h"
#include "radar.h"

static const int TargetCount = 50;

MainWindow::MainWindow()
{
    createActions();
    createMenus();    
    createToolbars();
    statusBar()->showMessage(tr("Ready"));

    qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));

    scene = new QGraphicsScene;
    scene->setSceneRect(-400, -300, 800, 600);
    scene->setItemIndexMethod(QGraphicsScene::NoIndex);

    for (int i = 0; i < TargetCount; ++i) {
        Target *target = new Target;
        target->setPos(qrand() % 800 - 400,
                       qrand() % 600 - 300);
		target->setVisible(true);
        scene->addItem(target);
    }

    view = new RadarView(scene, this);
    view->setRenderHint(QPainter::Antialiasing);
    view->setBackgroundBrush(Qt::black);
    view->setCacheMode(QGraphicsView::CacheBackground);
    view->setDragMode(QGraphicsView::ScrollHandDrag);

    setCentralWidget(view);
   	setWindowTitle(tr("海战模拟"));
}


void MainWindow::createActions()
{
}

void MainWindow::createMenus()
{
}

void MainWindow::createToolbars()
{
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -