Results 1 to 6 of 6

Thread: Button in OpenGL

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2008
    Location
    Algarve, Portugal
    Posts
    288
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60
    Thanks
    23
    Thanked 32 Times in 28 Posts

    Default Re: Button in OpenGL

    your Button1 gets out of scope has the constructor exit. Try declaring it as a pointer.
    __________________________________________________
    My projects: calculator MathGraphica ; SuperEpicMegaHero game ; GooglePlay ; bitbucket ; github
    Like my projects ? Buy me a kofi

  2. #2
    Join Date
    Jun 2011
    Posts
    203
    Qt products
    Qt4
    Platforms
    MacOS X Windows
    Thanks
    7
    Thanked 4 Times in 3 Posts

    Default Re: Button in OpenGL

    Hi John, thanks, got it to work. Another question. I would like to create different types of buttons e.g. one that does something i.e. a function, one that outputs a value such as a letter or something... for this, I've written different initialiser lists. However I'm not sure whether this is enough to differentiate between the buttons upon instantiation. i.e. when I instantiate a function button, I want it to do a callback or send out a signal (Qt) that will then be received somewhere else and do something... so in this case all I want to do is specify that this button is a function button. However if I want to create a button that spits out a letter, I want to be able to assign a letter to that button upon instantiation/initialisation. Since the button has many different member variables, if I create a particular instance of a button, what happens to the unused class member variables? Do they acquire the default constructor values... do they remain uninitialised? Not sure if I've explained myself clearly enough.

    Also... another question... lets say I create an object, is it possible to somehow pass the actual name of the object without needing to implement an additional member variable inside the class and declaring the name of that object upon instantiation of that object?
    Last edited by Atomic_Sheep; 5th September 2012 at 10:42.

  3. #3
    Join Date
    Aug 2008
    Location
    Algarve, Portugal
    Posts
    288
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60
    Thanks
    23
    Thanked 32 Times in 28 Posts

    Default Re: Button in OpenGL

    Not sure if I understand your questions, but you can define diferent constructors to define diferent member initialization/function calls when instantiating. If you are coding lots of diferent buttons perhaps you should consider using derived class buttons, to get a cleaner code and cleaner logic. If you do that, for the name of the object, you can avoid member variable, using just one method, something like this:

    class ButtonA : public Button
    {
    public:
    ButtonA();
    virtual QString name() const{return "buttonA";}
    .........
    }
    You will not need to set the object name at construction time, and will be able to get it whenever you want it.
    __________________________________________________
    My projects: calculator MathGraphica ; SuperEpicMegaHero game ; GooglePlay ; bitbucket ; github
    Like my projects ? Buy me a kofi

  4. #4
    Join Date
    Jun 2011
    Posts
    203
    Qt products
    Qt4
    Platforms
    MacOS X Windows
    Thanks
    7
    Thanked 4 Times in 3 Posts

    Default Re: Button in OpenGL

    Ah yes good point, I actually started doing this this way a few months back when I started this problem and have since forgotten that I did it this way. I'll look into it again. My concern was simply the fact that some initialiser lists don't address various member variables or functions and that's what I was worried about since my understanding is that the default constructor isn't called if you call an overloaded one.

Similar Threads

  1. OpenGL Rotation with only left button
    By danielperaza in forum Qt Programming
    Replies: 14
    Last Post: 7th August 2014, 09:35
  2. Replies: 2
    Last Post: 26th April 2011, 11:44
  3. Replies: 6
    Last Post: 21st August 2010, 21:09
  4. Replies: 0
    Last Post: 6th December 2009, 00:41
  5. Qt with OpenGL ES for ARM9 - All OpenGL ES tests have failed!
    By vinpa in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 3rd December 2009, 10:10

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.