Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class CComponent{
- public:
- QString ComponentID;
- QString ComponentType;
- int ComponentX;
- int ComponentY;
- int ComponentWidth;
- int ComponentHeight;
- int ComponentZOrder;
- int ComponentAspectRatio;
- int Transparent;
- int Red;
- int Green;
- int Blue;
- void SetComponentID(QString ID){
- ComponentID = ID;
- }
- void SetComponentType(QString Type){
- ComponentType = Type;
- }
- void SetComponentX(int X){
- ComponentX = X;
- }
- void SetComponentY(int Y){
- ComponentY = Y;
- }
- void SetComponentWidth(int Width){
- ComponentWidth = Width;
- }
- void SetComponentHeight(int Height){
- ComponentHeight = Height;
- }
- void SetComponentZOrder(int Z){
- ComponentZOrder = Z;
- }
- void SetComponentAspectRatio(int AS){
- ComponentAspectRatio = AS;
- }
- void SetComponentBackgroundTransparent(int T){
- Transparent = T;
- }
- void SetComponentBackgroundRed(int red){
- Red = red;
- }
- void SetComponentBackgroundGreen(int green){
- Green = green;
- }
- void SetComponentBackgroundBlue(int blue){
- Blue = blue;
- }
- };
- int main(int argc, char **argv)
- {
- QApplication app(argc, argv);
- qsrand(QTime(0, 0, 0).secsTo(QTime::currentTime()));
- QXmlGet xmlGet;
- xmlGet.load("/opt/TMP00000000.xml");
- QLinkedList<CComponent> ComponentList;
- CComponent ComponentTemplate;
- while (xmlGet.findNextAndDescend("Component"))
- {
- QString ComponentID = xmlGet.getAttributeString("ID","unknown");
- QString ComponentType = xmlGet.getAttributeString("Type","unknown");
- int ComponentX = xmlGet.getAttributeInt("X");
- int ComponentY = xmlGet.getAttributeInt("Y");
- int ComponentWidth = xmlGet.getAttributeInt("Width");
- int ComponentHeight = xmlGet.getAttributeInt("Height");
- int ComponentZOrder = xmlGet.getAttributeInt("ZOrder");
- int ComponentAspectRatio = xmlGet.getAttributeInt("AspectRatio");
- ComponentTemplate.SetComponentID(ComponentID);
- ComponentTemplate.SetComponentType(ComponentType);
- ComponentTemplate.SetComponentX(ComponentX);
- ComponentTemplate.SetComponentY(ComponentY);
- ComponentTemplate.SetComponentWidth(ComponentWidth);
- ComponentTemplate.SetComponentHeight(ComponentHeight);
- ComponentTemplate.SetComponentZOrder(ComponentZOrder);
- ComponentTemplate.SetComponentAspectRatio(ComponentAspectRatio);
- ComponentList.append(ComponentTemplate);
- qDebug()<<"ComponentID is "<<ComponentID;
- qDebug()<<"ComponentType is "<<ComponentType;
- qDebug()<<"ComponentX is "<<ComponentX;
- qDebug()<<"ComponentY is "<<ComponentY;
- qDebug()<<"ComponentWidth is "<<ComponentWidth;
- qDebug()<<"ComponentHeight is "<<ComponentHeight;
- qDebug()<<"ComponentZOrder is "<<ComponentZOrder;
- qDebug()<<"ComponentAspectRatio is "<<ComponentAspectRatio;
- if (xmlGet.findNext("Background"))
- {
- int Transparent = xmlGet.getAttributeInt("Transparent");
- int Red = xmlGet.getAttributeInt("Red");
- int Green = xmlGet.getAttributeInt("Green");
- int Blue = xmlGet.getAttributeInt("Blue");
- ComponentTemplate.SetComponentBackgroundTransparent(Transparent);
- ComponentTemplate.SetComponentBackgroundRed(Red);
- ComponentTemplate.SetComponentBackgroundGreen(Green);
- ComponentTemplate.SetComponentBackgroundBlue(Blue);
- qDebug()<<"BackgroundTransparent is "<<Transparent;
- qDebug()<<"BackgroundRed is "<<Red;
- qDebug()<<"BackgroundGreen is "<<Green;
- qDebug()<<"BackgroundBlue is "<<Blue;
- qDebug()<<QT_VERSION_STR;
- }
- xmlGet.rise();
- ComponentList.append(ComponentTemplate);
- }
- for(i=0 ;i<3 ;i++)
- {
- }
- foreach(QString s, ComponentList) qDebug()<< s;
- QGraphicsScene scene;
- scene.setSceneRect(-300, -300, 600, 600);
- scene.setItemIndexMethod(QGraphicsScene::NoIndex);
- for (int i = 0; i < MouseCount; ++i) {
- Mouse *mouse = new Mouse;
- mouse->setPos(::sin((i * 6.28) / MouseCount) * 200,
- ::cos((i * 6.28) / MouseCount) * 200);
- scene.addItem(mouse);
- }
- WidgetCircle *circleTest = new WidgetCircle;
- WidgetCountdown *CountdownTest = new WidgetCountdown;
- WidgetMarqueeLabel *MarqueeTest = new WidgetMarqueeLabel;
- DigitalClock *ClockTest = new DigitalClock;
- QVideoWidget *videoTest = new QVideoWidget;
- //videoTest
- MarqueeTest->setDirection(1);
- MarqueeTest->setSpeed(1);
- MarqueeTest->setText("How are you everyone everybody ");
- QGraphicsProxyWidget *proxy = scene.addWidget(CountdownTest);
- //proxy->setPos(30,30);
- // proxy->setPos(::sin((6.28) ) * 200,
- // ::cos((6.28) ) * 200);
- proxy->setPos(-200,-200);
- // proxy->setPos(100,100);
- proxy->moveBy(4,4);
- // TimeGraphics *timerWidget = new TimeGraphics;
- // // scene.addItem(timerWidget);
- // MyRect *rect = new MyRect;
- // QGraphicsProxyWidget *proxy = scene.addWidget(rect);
- /*
- MyRect *rect = new MyRect();
- rect->setRect(60,60,100,100);
- scene.addItem(rect);
- scene.addText("Hello /n There eVeryOne /n every where");
- scene.addSimpleText(" How are you");
- myGraphicsWidget* graphicsWidget = new myGraphicsWidget("This is my custom");
- scene.addItem(graphicsWidget);
- QGraphicsTextItem* item1 = new QGraphicsTextItem("QGraphicsTextItem Text Colro1");
- QGraphicsTextItem* item2 = new QGraphicsTextItem("Hellow there ");
- item1->setDefaultTextColor(Qt::red);
- item2->setDefaultTextColor(Qt::blue);
- scene.addItem(item1);
- scene.addItem(item2);
- item1->setRotation(30);
- item2->setRotation(60);
- item1->setPos(200,200);
- item2->setPos(-120,-120);
- */
- QGraphicsView view(&scene);
- view.setRenderHint(QPainter::Antialiasing);
- //view.setBackgroundBrush(QPixmap(":/images/cheese.jpg"));
- view.setCacheMode(QGraphicsView::CacheBackground);
- view.setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
- view.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
- view.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
- //view.setDragMode(QGraphicsView::ScrollHandDrag);
- view.setWindowTitle(QT_TRANSLATE_NOOP(QGraphicsView, "Colliding Mice"));
- view.resize(400, 300);
- view.show();
- int ItemCount = 1;
- for (int i =0; i< ItemCount; i++)
- {
- BoxAnimation *item = new BoxAnimation();
- scene.addItem(item);
- }
- QTimer timer;
- QObject::connect(&timer, SIGNAL(timeout()), &scene, SLOT(advance()));
- timer.start(1000 / 33);
- return app.exec();
- }
- //! [6]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement