Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QPushButton not appearing on scene [SOLVED]
Forum Updated to NodeBB v4.3 + New Features

QPushButton not appearing on scene [SOLVED]

Scheduled Pinned Locked Moved General and Desktop
qpushbutton
5 Posts 2 Posters 5.6k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nanoandrew4
    wrote on last edited by nanoandrew4
    #1

    When I try to add a QPushButton to the screen after a bool is declared true, it doesn't show up where it is supposed to. Here is the code. To be clear, I am adding the button from a non-constructor function, in case it is relevant. All pointers have been declared in the header file (not a typo), and will post if necessary, just don't want to make you look through all the code if not necessary. The scene is declared in the constructor from that same class.
    Thank you for your help!

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @nanoandrew4 said:

      , it doesn't show up it is supposed to

      So like it do not show at all or show in wrong position ?
      Maybe you need to call ->show() on it ?

      N 1 Reply Last reply
      0
      • mrjjM mrjj

        @nanoandrew4 said:

        , it doesn't show up it is supposed to

        So like it do not show at all or show in wrong position ?
        Maybe you need to call ->show() on it ?

        N Offline
        N Offline
        nanoandrew4
        wrote on last edited by nanoandrew4
        #3

        @mrjj Even after using show(); (which I forgot to include...) it is still not there when the crash bool is set to true. If you have more time and are willing to look through all the code for the project, it is right here on GitHub. The relevant class is Game (its where the button is). Still have to push all the changes, should be up withing a couple of minutes. It would rock too if you could tell me how to make the text (which is found in that same class) follow the QGraphicsView instead of the object, as when you start the game it does not appear until the plane is at a certain position. If you run the program yourself you will see what I mean.

        mrjjM 1 Reply Last reply
        0
        • N nanoandrew4

          @mrjj Even after using show(); (which I forgot to include...) it is still not there when the crash bool is set to true. If you have more time and are willing to look through all the code for the project, it is right here on GitHub. The relevant class is Game (its where the button is). Still have to push all the changes, should be up withing a couple of minutes. It would rock too if you could tell me how to make the text (which is found in that same class) follow the QGraphicsView instead of the object, as when you start the game it does not appear until the plane is at a certain position. If you run the program yourself you will see what I mean.

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by mrjj
          #4

          @nanoandrew4
          Hi way cool code :)
          Your setGeometry is just off
          if I say
          replay = new QPushButton("Replay", this);
          replay->show();
          //replay->setGeometry(QRect(QPoint(4500, 400), QSize(100,50)));

          It comes in top, left corner. so my guess the 4500 is way to much ?
          update:
          yep if I change it to 450, its on screen. :)
          update2:
          you did not have a
          replay->show();

          N 1 Reply Last reply
          0
          • mrjjM mrjj

            @nanoandrew4
            Hi way cool code :)
            Your setGeometry is just off
            if I say
            replay = new QPushButton("Replay", this);
            replay->show();
            //replay->setGeometry(QRect(QPoint(4500, 400), QSize(100,50)));

            It comes in top, left corner. so my guess the 4500 is way to much ?
            update:
            yep if I change it to 450, its on screen. :)
            update2:
            you did not have a
            replay->show();

            N Offline
            N Offline
            nanoandrew4
            wrote on last edited by
            #5

            @mrjj Thank you so much, for some reason I always forget I need to use the show() function...
            Thank you for the help, and if you have any more suggestions please do comment or drop a line on my GitHub page. This is just my iniciation project, will be moving on to something larger soon. Thanks again!

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved