can now add new components

This commit is contained in:
Robert 2020-12-01 16:20:19 +01:00
parent edf6a0ad2b
commit 96f2cffbcc
3 changed files with 7 additions and 37 deletions

View file

@ -16,9 +16,7 @@ Component::Component(QWidget* parent, const QString& resource) :
ui = new Ui::Component();
ui->setupUi(this);
ui->label->setPixmap(QPixmap(":/components/and.png"));
std::cout << "Created Component --" << ui->label->pos().x() << ", " << ui->label->pos().y() << std::endl;
ui->label->setPixmap(QPixmap(resource));
}
void Component::mouseMoveEvent(QMouseEvent* event)

View file

@ -62,17 +62,13 @@ void Window::mousePressEvent(QMouseEvent* event)
if (child != nullptr)
return;
// So Qt can't add widgets outside of the constructor apparently
// So component cannot be a QFrame, it will have to become just a normal object
// And I need one of these open gl gsjdööööööööööööööl<
// TODO: I'll just let this leak for now, I just wanna eat dinner...
Component* leak = new Component(this, resourcePath);
QPoint pos = event->pos() - QPoint {50, 25};
leak->setGeometry(QRect(280, 160, 100, 50));
leak->setFrameShape(QFrame::StyledPanel);
leak->setFrameShadow(QFrame::Raised);
std::cout << leak->pos().x() << ", " << leak->pos().y() << std::endl;
leak->setGeometry(QRect(pos.x(), pos.y(), 100, 50));
leak->setFrameShape(QFrame::NoFrame);
leak->setFrameShadow(QFrame::Plain);
leak->setVisible(true);
}
}
@ -118,6 +114,7 @@ void Window::LoadGhostLabel(const QString& resource)
ghostImage = new GhostLabel(this);
ghostImage->setGeometry({ 0, 0, 100, 50 });
ghostImage->setScaledContents(true);
ghostImage->setVisible(true);
}
QPainter p;

View file

@ -16,24 +16,7 @@
<property name="dockOptions">
<set>QMainWindow::AnimatedDocks</set>
</property>
<widget class="QWidget" name="centralwidget">
<widget class="Component" name="frame">
<property name="geometry">
<rect>
<x>360</x>
<y>180</y>
<width>120</width>
<height>80</height>
</rect>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</widget>
<widget class="QWidget" name="centralwidget"/>
<widget class="QStatusBar" name="statusbar"/>
<widget class="QToolBar" name="toolBar">
<property name="windowTitle">
@ -106,14 +89,6 @@
</property>
</action>
</widget>
<customwidgets>
<customwidget>
<class>Component</class>
<extends>QFrame</extends>
<header>Component.hpp</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="assets/resources.qrc"/>
</resources>