nice way to get main window
This commit is contained in:
parent
d8d38cd107
commit
9f8bdd3c3e
@ -1,13 +1,24 @@
|
|||||||
#include "fpgaviewwidget.h"
|
#include "fpgaviewwidget.h"
|
||||||
|
#include <QApplication>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
|
#include <QWidget>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
|
||||||
FPGAViewWidget::FPGAViewWidget(QWidget *parent)
|
FPGAViewWidget::FPGAViewWidget(QWidget *parent)
|
||||||
: QOpenGLWidget(parent), m_xMove(0), m_yMove(0), m_zDistance(1.0)
|
: QOpenGLWidget(parent), m_xMove(0), m_yMove(0), m_zDistance(1.0)
|
||||||
{
|
{
|
||||||
design = qobject_cast<MainWindow*>(parentWidget()->parentWidget()->parentWidget()->parentWidget())->getDesign();
|
design = qobject_cast<MainWindow *>(getMainWindow())->getDesign();
|
||||||
|
}
|
||||||
|
|
||||||
|
QMainWindow *FPGAViewWidget::getMainWindow()
|
||||||
|
{
|
||||||
|
QWidgetList widgets = qApp->topLevelWidgets();
|
||||||
|
for (QWidgetList::iterator i = widgets.begin(); i != widgets.end(); ++i)
|
||||||
|
if ((*i)->objectName() == "MainWindow")
|
||||||
|
return (QMainWindow *)(*i);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
FPGAViewWidget::~FPGAViewWidget() {}
|
FPGAViewWidget::~FPGAViewWidget() {}
|
||||||
@ -68,7 +79,6 @@ void FPGAViewWidget::drawElement(const GraphicElement &el)
|
|||||||
glVertex3f((offset + scale * el.x1), (offset + scale * el.y2), 0.0f);
|
glVertex3f((offset + scale * el.x1), (offset + scale * el.y2), 0.0f);
|
||||||
glVertex3f((offset + scale * el.x1), (offset + scale * el.y1), 0.0f);
|
glVertex3f((offset + scale * el.x1), (offset + scale * el.y1), 0.0f);
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (el.type == GraphicElement::G_LINE) {
|
if (el.type == GraphicElement::G_LINE) {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#ifndef MAPGLWIDGET_H
|
#ifndef MAPGLWIDGET_H
|
||||||
#define MAPGLWIDGET_H
|
#define MAPGLWIDGET_H
|
||||||
|
|
||||||
|
#include <QMainWindow>
|
||||||
#include <QOpenGLFunctions>
|
#include <QOpenGLFunctions>
|
||||||
#include <QOpenGLWidget>
|
#include <QOpenGLWidget>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
@ -33,6 +34,7 @@ class FPGAViewWidget : public QOpenGLWidget, protected QOpenGLFunctions
|
|||||||
void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
|
void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
|
||||||
void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE;
|
void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE;
|
||||||
void drawElement(const GraphicElement &el);
|
void drawElement(const GraphicElement &el);
|
||||||
|
QMainWindow *getMainWindow();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int m_windowWidth;
|
int m_windowWidth;
|
||||||
|
Loading…
Reference in New Issue
Block a user