成功显示了公交车的图片
This commit is contained in:
parent
fa843258ce
commit
5b2045675d
|
@ -1,8 +1,8 @@
|
|||
<RCC>
|
||||
<qresource prefix="/stop_pic">
|
||||
<qresource prefix="/">
|
||||
<file>picture/stop.png</file>
|
||||
</qresource>
|
||||
<qresource prefix="/bus_pic">
|
||||
<qresource prefix="/">
|
||||
<file>picture/bus.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
34
include/mainScene.h
Normal file
34
include/mainScene.h
Normal file
|
@ -0,0 +1,34 @@
|
|||
//
|
||||
// Created by ricardo on 2022/6/11.
|
||||
//
|
||||
|
||||
#ifndef AUTO_BUS_GUI_MAIN_SCENE_H
|
||||
#define AUTO_BUS_GUI_MAIN_SCENE_H
|
||||
|
||||
#include "QGraphicsScene"
|
||||
#include "QGraphicsPixmapItem"
|
||||
#include "railsModel.h"
|
||||
|
||||
class SceneManager
|
||||
{
|
||||
public:
|
||||
QGraphicsScene *scene;
|
||||
|
||||
~SceneManager();
|
||||
|
||||
/**
|
||||
* 初始化绘制场景
|
||||
*/
|
||||
void init();
|
||||
|
||||
/**
|
||||
* 初始化场景中的站点
|
||||
* @param rail_head 轨道的头节点
|
||||
*/
|
||||
void initBusStop(rail_node_t *rail_head);
|
||||
|
||||
private:
|
||||
QGraphicsPixmapItem *pixmap_items;
|
||||
};
|
||||
|
||||
#endif //AUTO_BUS_GUI_MAIN_SCENE_H
|
|
@ -6,15 +6,22 @@
|
|||
|
||||
#include "header/moc_centralwidget.cpp"
|
||||
#include "form/ui_CentralWidget.h"
|
||||
#include "centralwidget.h"
|
||||
|
||||
|
||||
CentralWidget::CentralWidget(QWidget *parent) :
|
||||
QWidget(parent), ui(new Ui::CentralWidget)
|
||||
CentralWidget::CentralWidget(QWidget *parent) : QWidget(parent), ui(new Ui::CentralWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
scene_manager = new SceneManager;
|
||||
scene_manager->init();
|
||||
scene_manager->initBusStop(nullptr);
|
||||
|
||||
ui->main_canva->setScene(scene_manager->scene);
|
||||
}
|
||||
|
||||
CentralWidget::~CentralWidget()
|
||||
{
|
||||
delete ui;
|
||||
delete scene_manager;
|
||||
}
|
||||
|
|
|
@ -6,20 +6,26 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>865</width>
|
||||
<height>635</height>
|
||||
<width>900</width>
|
||||
<height>600</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>900</width>
|
||||
<height>600</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>CentralWidget</string>
|
||||
</property>
|
||||
<widget class="QGraphicsView" name="graphicsView">
|
||||
<widget class="QGraphicsView" name="main_canva">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>661</width>
|
||||
<height>421</height>
|
||||
<width>600</width>
|
||||
<height>400</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
|
@ -29,10 +35,17 @@
|
|||
<x>659</x>
|
||||
<y>-1</y>
|
||||
<width>201</width>
|
||||
<height>421</height>
|
||||
<height>411</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="test_button">
|
||||
<property name="text">
|
||||
<string>测试输出</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
|
@ -42,28 +55,28 @@
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QScrollArea" name="scrollArea">
|
||||
<widget class="QTextEdit" name="text_output">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>420</y>
|
||||
<width>861</width>
|
||||
<height>221</height>
|
||||
<y>400</y>
|
||||
<width>900</width>
|
||||
<height>190</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</widget>
|
||||
<widget class="Line" name="line">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>400</y>
|
||||
<width>900</width>
|
||||
<height>10</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>859</width>
|
||||
<height>219</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
|
|
|
@ -7,9 +7,21 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>900</width>
|
||||
<height>600</height>
|
||||
<height>622</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>900</width>
|
||||
<height>622</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>900</width>
|
||||
<height>622</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
|
|
|
@ -2,11 +2,12 @@
|
|||
// Created by ricardo on 2022/6/10.
|
||||
//
|
||||
|
||||
#ifndef AUTO_BUS_GUI_CENTRALWIDGET_H
|
||||
#define AUTO_BUS_GUI_CENTRALWIDGET_H
|
||||
#ifndef AUTO_BUS_GUI_CENTRAL_WIDGET_H
|
||||
#define AUTO_BUS_GUI_CENTRAL_WIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#include "string"
|
||||
#include "mainScene.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui
|
||||
|
@ -24,9 +25,13 @@ public:
|
|||
|
||||
~CentralWidget() override;
|
||||
|
||||
public slots:
|
||||
|
||||
|
||||
private:
|
||||
Ui::CentralWidget *ui;
|
||||
SceneManager *scene_manager;
|
||||
};
|
||||
|
||||
|
||||
#endif //AUTO_BUS_GUI_CENTRALWIDGET_H
|
||||
#endif //AUTO_BUS_GUI_CENTRAL_WIDGET_H
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
// Created by ricardo on 2022/6/10.
|
||||
//
|
||||
|
||||
#ifndef AUTO_BUS_GUI_MAINWINDOW_H
|
||||
#define AUTO_BUS_GUI_MAINWINDOW_H
|
||||
#ifndef AUTO_BUS_GUI_MAIN_WINDOW_H
|
||||
#define AUTO_BUS_GUI_MAIN_WINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include "centralwidget.h"
|
||||
|
@ -31,6 +31,4 @@ private:
|
|||
|
||||
void SetMenuBarConnection();
|
||||
};
|
||||
|
||||
|
||||
#endif //AUTO_BUS_GUI_MAINWINDOW_H
|
||||
#endif //AUTO_BUS_GUI_MAIN_WINDOW_H
|
||||
|
|
26
src/mainScene.cpp
Normal file
26
src/mainScene.cpp
Normal file
|
@ -0,0 +1,26 @@
|
|||
//
|
||||
// Created by ricardo on 2022/6/11.
|
||||
//
|
||||
|
||||
#include "mainScene.h"
|
||||
|
||||
void SceneManager::init()
|
||||
{
|
||||
scene = new QGraphicsScene;
|
||||
}
|
||||
|
||||
void SceneManager::initBusStop(rail_node_t *rail_head)
|
||||
{
|
||||
pixmap_items = new QGraphicsPixmapItem[1];
|
||||
|
||||
pixmap_items->setPixmap(QPixmap(":/picture/bus.png"));
|
||||
pixmap_items->setPos(100,100);
|
||||
|
||||
scene->addItem(pixmap_items);
|
||||
}
|
||||
|
||||
SceneManager::~SceneManager()
|
||||
{
|
||||
delete []pixmap_items;
|
||||
delete scene;
|
||||
}
|
Loading…
Reference in New Issue
Block a user