پاسخ داده شده: چطور می شود در کیوت (Qt) اشیاء با قابلیت جابجایی را در صفحه ایجاد کرد و آنها را با یک خط اتصال داد؟
حالا از اون کلاس resizable ی که ایجاد کردیم میام shape مورد نظر خودمونو می سازیم من به طور مثال rectagle را به شما نشان میدم بقیه موارد را بر طبق همین بسازید.
#ifndef ECV_RESIZABLE_GRAPHICS_RECT #define ECV_RESIZABLE_GRAPHICS_RECT #include "viewlib_global.h" #include "EcvResizableGraphicsItem.h" namespace ecv { extern const int HANDLE_SIZE ; class VIEWLIB_EXPORT EcvResizableGraphicsRect : public EcvResizableGraphicsItem { public: EcvResizableGraphicsRect(const EcvObjectData& data, int handel_size = HANDLE_SIZE, QGraphicsItem *parent = 0); virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); private: }; }//ecv #endif //ECV_RESIZABLE_GRAPHICS_RECT
#include "EcvResizableGraphicsRect.h" #include <QPainter> namespace ecv { EcvResizableGraphicsRect::EcvResizableGraphicsRect(const EcvObjectData & data, int handel_size, QGraphicsItem * parent): EcvResizableGraphicsItem(data,handel_size,parent) { } void EcvResizableGraphicsRect::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget /*= 0*/) { if (widget) { EcvResizableGraphicsItem::paint(painter, option, widget); painter->drawRect(data().rect()); //for (size_t i = 0; i < 8; i++) { // //painter->drawRect(getSqure(handle_points_[i])); // int next_i = (i + 1) % 8; // auto line = getLine(handle_points_[i], handle_points_[next_i], handle_size_); // painter->drawLine(line); //} } } }//ecv