Results 1 to 12 of 12

Thread: Pixmap updating QLabel

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #4
    Join Date
    May 2009
    Location
    Canada
    Posts
    163
    Thanks
    7
    Thanked 20 Times in 20 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Windows Android

    Default Re: Pixmap updating QLabel

    When you declare a variable in a header file, that variable is considered to be an integral part of any object instantiated from your class. Thus, it persists until the object is destroyed. These so-called "instance variables" are generally initialized in the constructor, a method with the same name as your class. When you say "QLabel *label = new QLabel()", you are in fact calling the default constructor (i.e., no parameters) of the QLabel class.

    In C++ you can create a variable on the stack or on the heap. When you say "type *var = new type();", you are putting the variable on the heap, and even if you do this inside a method, the variable will persist. On the other hand, if you say "type var;" then you are putting the variable on the stack. If you do this inside a brace-delimited scope (such as a method), the variable will not persist or be visible outside that scope unless you take a pointer to it first. This conforms to the idea of a local variable.

  2. The following user says thank you to Urthas for this useful post:

    Matt (17th August 2010)

Similar Threads

  1. DB changes not updating in views
    By Jeffb in forum Newbie
    Replies: 11
    Last Post: 11th May 2010, 10:00
  2. Replies: 1
    Last Post: 29th September 2009, 19:44
  3. Updating from Qt-4.4.3 to Qt-4.5.0 --Help Needed
    By swamyonline in forum Installation and Deployment
    Replies: 1
    Last Post: 9th February 2009, 11:37
  4. Replies: 1
    Last Post: 2nd August 2008, 15:46
  5. empty pixmap as a QLabel
    By tommy in forum Qt Programming
    Replies: 16
    Last Post: 11th December 2007, 21:15

Tags for this Thread

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.