Title: tutorial6: when and why do I have to add *parent as a class parameter and when not? · Issue #5 · MeLikeyCode/QtGameTutorial · GitHub
Open Graph Title: tutorial6: when and why do I have to add *parent as a class parameter and when not? · Issue #5 · MeLikeyCode/QtGameTutorial
X Title: tutorial6: when and why do I have to add *parent as a class parameter and when not? · Issue #5 · MeLikeyCode/QtGameTutorial
Description: hi, as tp tutorial6: when do I have to add *parent as a class parameter and when not? e.g., not: .cpp Bullet::Bullet(): QObject(), QGraphicsRectItem(){ setRect(0,0,10,50); QTimer * timer = new QTimer(this); connect(timer,SIGNAL(timeout()...
Open Graph Description: hi, as tp tutorial6: when do I have to add *parent as a class parameter and when not? e.g., not: .cpp Bullet::Bullet(): QObject(), QGraphicsRectItem(){ setRect(0,0,10,50); QTimer * timer = new QTim...
X Description: hi, as tp tutorial6: when do I have to add *parent as a class parameter and when not? e.g., not: .cpp Bullet::Bullet(): QObject(), QGraphicsRectItem(){ setRect(0,0,10,50); QTimer * timer = new QTim...
Opengraph URL: https://github.com/MeLikeyCode/QtGameTutorial/issues/5
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"tutorial6: when and why do I have to add *parent as a class parameter and when not?","articleBody":"hi,\r\nas tp tutorial6:\r\nwhen do I have to add *parent as a class parameter and when not?\r\n\r\ne.g., not:\r\n.cpp\r\n```\r\n\r\nBullet::Bullet(): QObject(), QGraphicsRectItem(){\r\n setRect(0,0,10,50);\r\n QTimer * timer = new QTimer(this);\r\n connect(timer,SIGNAL(timeout()),this,SLOT(move()));\r\n timer-\u003estart(50);\r\n}\r\n\r\n```\r\nheader:\r\n```\r\nclass Bullet: public QObject, public QGraphicsRectItem{\r\n Q_OBJECT\r\npublic:\r\n Bullet(QGraphicsItem * parent=0); // parent only in header\r\npublic slots:\r\n void move();\r\n};\r\n\r\n```\r\n\r\n\r\n\r\nbut e.g., yes:\r\n.cpp\r\n```\r\n\r\nEnemy::Enemy(QGraphicsItem *parent): QObject(), QGraphicsRectItem(parent){ // \u003c\u003c\u003c\u003c\u003c\u003c\u003c\u003c\u003c\u003c\u003c\u003c\u003c\u003c\u003c\u003c\u003c\u003c\u003c\u003c\u003c\u003c\u003c\u003c\u003c\u003c\u003c\r\n int random_number = rand() % 700;\r\n setPos(random_number,0);\r\n setRect(0,0,100,100);\r\n QTimer * timer = new QTimer(this);\r\n connect(timer,SIGNAL(timeout()),this,SLOT(move()));\r\n timer-\u003estart(50);\r\n}\r\n\r\n```\r\nheader:\r\n```\r\nclass Enemy: public QObject, public QGraphicsRectItem{\r\n Q_OBJECT\r\npublic:\r\n Enemy(QGraphicsItem * parent=0); // parent in header like above\r\npublic slots:\r\n void move();\r\n};\r\n\r\n```\r\n\r\ni.e., why can't I just declare \r\nEnemy::Enemy(): QObject(), QGraphicsRectItem(){ ...}[/code]`\r\n similar to the Bullet file?\r\n\r\n(ref.: https://github.com/MeLikeyCode/QtGameTutorial/tree/master/tutorial6)\r\n\r\n(edit, \r\nBTW, in previous tutorials https://github.com/MeLikeyCode/QtGameTutorial/tree/master/tutorial1 ... https://github.com/MeLikeyCode/QtGameTutorial/tree/master/tutorial5 this \"parents\" thing has not been added at all for either class)","author":{"url":"https://github.com/dsyleixa","@type":"Person","name":"dsyleixa"},"datePublished":"2023-07-09T13:06:08.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/5/QtGameTutorial/issues/5"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:938a9927-e373-750d-68ad-d1ff7e165d1a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | EE42:240924:1A86780:2404092:6A62F364 |
| html-safe-nonce | 3337876486384afc8423103d6176bbbe841adb73ec2e1cf5d7faacda66efa439 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFRTQyOjI0MDkyNDoxQTg2NzgwOjI0MDQwOTI6NkE2MkYzNjQiLCJ2aXNpdG9yX2lkIjoiNDIxNTQyNjI4NjU0NzgxMiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 8e7a613f94a1a9aa4a20974a38a3e197061b89462780228bdd2650c9126e6203 |
| hovercard-subject-tag | issue:1795394126 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/MeLikeyCode/QtGameTutorial/5/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d38b4882204d5d43e35c0dbc2308932bffd0184bf19a527d3797e6fe404dbcec/MeLikeyCode/QtGameTutorial/issues/5 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d38b4882204d5d43e35c0dbc2308932bffd0184bf19a527d3797e6fe404dbcec/MeLikeyCode/QtGameTutorial/issues/5 |
| og:image:alt | hi, as tp tutorial6: when do I have to add *parent as a class parameter and when not? e.g., not: .cpp Bullet::Bullet(): QObject(), QGraphicsRectItem(){ setRect(0,0,10,50); QTimer * timer = new QTim... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dsyleixa |
| hostname | github.com |
| expected-hostname | github.com |
| None | b415018e190e73858133ddcaa36acce7b3f3572fe54dda84bd3b21a6ec714c30 |
| turbo-cache-control | no-preview |
| go-import | github.com/MeLikeyCode/QtGameTutorial git https://github.com/MeLikeyCode/QtGameTutorial.git |
| octolytics-dimension-user_id | 6657427 |
| octolytics-dimension-user_login | MeLikeyCode |
| octolytics-dimension-repository_id | 26611464 |
| octolytics-dimension-repository_nwo | MeLikeyCode/QtGameTutorial |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 26611464 |
| octolytics-dimension-repository_network_root_nwo | MeLikeyCode/QtGameTutorial |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 22f98521e99f504294ab0812b66104d50eb75a70 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width