Advertisement
houmingc

Iterator CComponent Error

May 15th, 2015
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.51 KB | None | 0 0
  1. #include <QtWidgets>
  2. #include <math.h>
  3. #include "mouse.h"
  4. #include "customgraphicsitems.h"
  5. #include "mygraphicswidget.h"
  6. #include <QGraphicsBlurEffect>
  7. #include "myrect.h"
  8. #include "timegraphics.h"
  9. #include "QGraphicsProxyWidget"
  10. #include "widgetcircle.h"
  11. #include "widgetcountdown.h"
  12. #include "WidgetMarqueeLabel.h"
  13. #include "wigglywidget.h"
  14. #include "digitalclock.h"
  15. #include "qxmlputget.h"
  16. #include <QLinkedList>
  17. #include <qvideowidget.h>
  18. #include <qvideosurfaceformat.h>
  19. #include "boxanimation.h"
  20. #include <QString>
  21.  
  22. static const int MouseCount = 7;
  23.  
  24.  
  25. class CComponent{
  26. public:
  27. QString ComponentID;
  28. QString ComponentType;
  29. int ComponentX;
  30. int ComponentY;
  31. int ComponentWidth;
  32. int ComponentHeight;
  33. int ComponentZOrder;
  34. int ComponentAspectRatio;
  35. int Transparent;
  36. int Red;
  37. int Green;
  38. int Blue;
  39.  
  40. void SetComponentID(QString ID){
  41. ComponentID = ID;
  42. }
  43. void SetComponentType(QString Type){
  44. ComponentType = Type;
  45. }
  46. void SetComponentX(int X){
  47. ComponentX = X;
  48. }
  49. void SetComponentY(int Y){
  50. ComponentY = Y;
  51. }
  52. void SetComponentWidth(int Width){
  53. ComponentWidth = Width;
  54. }
  55. void SetComponentHeight(int Height){
  56. ComponentHeight = Height;
  57. }
  58. void SetComponentZOrder(int Z){
  59. ComponentZOrder = Z;
  60. }
  61. void SetComponentAspectRatio(int AS){
  62. ComponentAspectRatio = AS;
  63. }
  64. void SetComponentBackgroundTransparent(int T){
  65. Transparent = T;
  66. }
  67. void SetComponentBackgroundRed(int red){
  68. Red = red;
  69. }
  70. void SetComponentBackgroundGreen(int green){
  71. Green = green;
  72. }
  73. void SetComponentBackgroundBlue(int blue){
  74. Blue = blue;
  75. }
  76.  
  77. QString GetComponentID() const{
  78. return ComponentID;
  79. }
  80. QString GetComponentType() const{
  81. return ComponentType;
  82. }
  83. int GetComponentX() const{
  84. return ComponentX;
  85. }
  86. int GetComponentY() const{
  87. return ComponentY;
  88. }
  89. int GetComponentWidth() const{
  90. return ComponentWidth;
  91. }
  92. int GetComponentHeight() const{
  93. return ComponentHeight;
  94. }
  95. int GetComponentZOrder() const{
  96. return ComponentZOrder;
  97. }
  98. int GetComponentAspectRatio() const{
  99. return ComponentAspectRatio;
  100. }
  101. int GetComponentBackgroundTransparent() const{
  102. return Transparent;
  103. }
  104. int GetComponentBackgroundRed() const{
  105. return Red;
  106. }
  107. int GetComponentBackgroundGreen() const{
  108. return Green;
  109. }
  110. int GetComponentBackgroundBlue() const{
  111. return Blue;
  112. }
  113.  
  114.  
  115.  
  116.  
  117.  
  118. };
  119.  
  120.  
  121.  
  122.  
  123. int main(int argc, char **argv)
  124. {
  125. QApplication app(argc, argv);
  126. qsrand(QTime(0, 0, 0).secsTo(QTime::currentTime()));
  127.  
  128. QXmlGet xmlGet;
  129. xmlGet.load("/opt/TMP00000000.xml");
  130. QLinkedList<CComponent> ComponentList;
  131. CComponent ComponentTemplate;
  132. while (xmlGet.findNextAndDescend("Component"))
  133. {
  134.  
  135. QString ComponentID = xmlGet.getAttributeString("ID","unknown");
  136. QString ComponentType = xmlGet.getAttributeString("Type","unknown");
  137. int ComponentX = xmlGet.getAttributeInt("X");
  138. int ComponentY = xmlGet.getAttributeInt("Y");
  139. int ComponentWidth = xmlGet.getAttributeInt("Width");
  140. int ComponentHeight = xmlGet.getAttributeInt("Height");
  141. int ComponentZOrder = xmlGet.getAttributeInt("ZOrder");
  142. int ComponentAspectRatio = xmlGet.getAttributeInt("AspectRatio");
  143.  
  144. ComponentTemplate.SetComponentID(ComponentID);
  145. ComponentTemplate.SetComponentType(ComponentType);
  146. ComponentTemplate.SetComponentX(ComponentX);
  147. ComponentTemplate.SetComponentY(ComponentY);
  148. ComponentTemplate.SetComponentWidth(ComponentWidth);
  149. ComponentTemplate.SetComponentHeight(ComponentHeight);
  150. ComponentTemplate.SetComponentZOrder(ComponentZOrder);
  151. ComponentTemplate.SetComponentAspectRatio(ComponentAspectRatio);
  152.  
  153.  
  154. ComponentList.append(ComponentTemplate);
  155.  
  156.  
  157. qDebug()<<"ComponentID is "<<ComponentID;
  158. qDebug()<<"ComponentType is "<<ComponentType;
  159. qDebug()<<"ComponentX is "<<ComponentX;
  160. qDebug()<<"ComponentY is "<<ComponentY;
  161. qDebug()<<"ComponentWidth is "<<ComponentWidth;
  162. qDebug()<<"ComponentHeight is "<<ComponentHeight;
  163. qDebug()<<"ComponentZOrder is "<<ComponentZOrder;
  164. qDebug()<<"ComponentAspectRatio is "<<ComponentAspectRatio;
  165.  
  166. if (xmlGet.findNext("Background"))
  167. {
  168. int Transparent = xmlGet.getAttributeInt("Transparent");
  169. int Red = xmlGet.getAttributeInt("Red");
  170. int Green = xmlGet.getAttributeInt("Green");
  171. int Blue = xmlGet.getAttributeInt("Blue");
  172.  
  173. ComponentTemplate.SetComponentBackgroundTransparent(Transparent);
  174. ComponentTemplate.SetComponentBackgroundRed(Red);
  175. ComponentTemplate.SetComponentBackgroundGreen(Green);
  176. ComponentTemplate.SetComponentBackgroundBlue(Blue);
  177.  
  178. qDebug()<<"BackgroundTransparent is "<<Transparent;
  179. qDebug()<<"BackgroundRed is "<<Red;
  180. qDebug()<<"BackgroundGreen is "<<Green;
  181. qDebug()<<"BackgroundBlue is "<<Blue;
  182. qDebug()<<QT_VERSION_STR;
  183. }
  184. xmlGet.rise();
  185. ComponentList.append(ComponentTemplate);
  186. }
  187.  
  188.  
  189. // QLinkedList<CComponent *> list;
  190.  
  191. // while(!list.isEmpty()) //T-> list no items
  192. // {
  193. // qDebug()<<"xxxx is "<<ComponentTemplate.ComponentX;
  194. // ++list;
  195. // }
  196.  
  197. QList<CComponent> list;
  198.  
  199. QListIterator<CComponent> i(list);
  200. while(i.hasNext()){
  201. qDebug() << i.next();
  202. }
  203.  
  204.  
  205. /*
  206. 1> need while loop to be continuously true
  207. 2> When True, list has no more Item.
  208. 3> while loop continuously when True,
  209.  
  210. */
  211. QGraphicsScene scene;
  212. scene.setSceneRect(-300, -300, 600, 600);
  213.  
  214. scene.setItemIndexMethod(QGraphicsScene::NoIndex);
  215.  
  216. for (int i = 0; i < MouseCount; ++i) {
  217. Mouse *mouse = new Mouse;
  218. mouse->setPos(::sin((i * 6.28) / MouseCount) * 200,
  219. ::cos((i * 6.28) / MouseCount) * 200);
  220. scene.addItem(mouse);
  221. }
  222.  
  223.  
  224. WidgetCircle *circleTest = new WidgetCircle;
  225. WidgetCountdown *CountdownTest = new WidgetCountdown;
  226. WidgetMarqueeLabel *MarqueeTest = new WidgetMarqueeLabel;
  227. DigitalClock *ClockTest = new DigitalClock;
  228. QVideoWidget *videoTest = new QVideoWidget;
  229.  
  230. //videoTest
  231.  
  232. MarqueeTest->setDirection(1);
  233. MarqueeTest->setSpeed(1);
  234. MarqueeTest->setText("How are you everyone everybody ");
  235.  
  236.  
  237.  
  238. QGraphicsProxyWidget *proxy = scene.addWidget(CountdownTest);
  239. //proxy->setPos(30,30);
  240. // proxy->setPos(::sin((6.28) ) * 200,
  241. // ::cos((6.28) ) * 200);
  242.  
  243. proxy->setPos(-200,-200);
  244. // proxy->setPos(100,100);
  245. proxy->moveBy(4,4);
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253. // TimeGraphics *timerWidget = new TimeGraphics;
  254. // // scene.addItem(timerWidget);
  255. // MyRect *rect = new MyRect;
  256.  
  257.  
  258. // QGraphicsProxyWidget *proxy = scene.addWidget(rect);
  259.  
  260.  
  261.  
  262. /*
  263. MyRect *rect = new MyRect();
  264. rect->setRect(60,60,100,100);
  265. scene.addItem(rect);
  266. scene.addText("Hello /n There eVeryOne /n every where");
  267. scene.addSimpleText(" How are you");
  268. myGraphicsWidget* graphicsWidget = new myGraphicsWidget("This is my custom");
  269. scene.addItem(graphicsWidget);
  270. QGraphicsTextItem* item1 = new QGraphicsTextItem("QGraphicsTextItem Text Colro1");
  271. QGraphicsTextItem* item2 = new QGraphicsTextItem("Hellow there ");
  272. item1->setDefaultTextColor(Qt::red);
  273. item2->setDefaultTextColor(Qt::blue);
  274. scene.addItem(item1);
  275. scene.addItem(item2);
  276. item1->setRotation(30);
  277. item2->setRotation(60);
  278. item1->setPos(200,200);
  279. item2->setPos(-120,-120);
  280. */
  281.  
  282.  
  283.  
  284.  
  285.  
  286. QGraphicsView view(&scene);
  287. view.setRenderHint(QPainter::Antialiasing);
  288. //view.setBackgroundBrush(QPixmap(":/images/cheese.jpg"));
  289.  
  290. view.setCacheMode(QGraphicsView::CacheBackground);
  291. view.setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
  292. view.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  293. view.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  294. //view.setDragMode(QGraphicsView::ScrollHandDrag);
  295.  
  296. view.setWindowTitle(QT_TRANSLATE_NOOP(QGraphicsView, "Colliding Mice"));
  297. view.resize(400, 300);
  298. view.show();
  299.  
  300.  
  301. int ItemCount = 1;
  302. for (int i =0; i< ItemCount; i++)
  303. {
  304. BoxAnimation *item = new BoxAnimation();
  305. scene.addItem(item);
  306.  
  307. }
  308.  
  309.  
  310.  
  311. QTimer timer;
  312. QObject::connect(&timer, SIGNAL(timeout()), &scene, SLOT(advance()));
  313. timer.start(1000 / 33);
  314.  
  315. return app.exec();
  316. }
  317. //! [6]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement