Results 1 to 7 of 7

Thread: QPainter Constructor Syntax Question

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #6
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QPainter Constructor Syntax Question

    The example that puzzles you is allocation on the stack. The bracketed part of the expression is the arguments to the QPainter constructor. If you wrote:
    Qt Code:
    To copy to clipboard, switch view to plain text mode 
    you would be creating a QPainter using its default (parameterless) constructor. The example you give uses a different constructor to build the QPainter and initialise it in some way. The constructor options are in the Assistant docs for QPainter. The same syntax can be used to initialise ('construct') basic types created on the stack:
    Qt Code:
    1. int x(9);
    2. char c('A');
    To copy to clipboard, switch view to plain text mode 

    You have given a (slightly incorrect) example of allocating the QPainter on the heap.
    Your second example may be either stack or heap (with the same missing * as your first) depending on what your fictious QPainter::fromWidget() is supposed to return (a pointer or an instance of QPainter).

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

    deejross (25th January 2011)

Similar Threads

  1. Qpainter in Constructor
    By augusbas in forum Newbie
    Replies: 4
    Last Post: 28th October 2010, 00:45
  2. qglwidget and constructor question on mac
    By john_god in forum Qt Programming
    Replies: 0
    Last Post: 17th June 2010, 00:51
  3. QtScript: default constructor question
    By QPlace in forum Qt Programming
    Replies: 1
    Last Post: 22nd October 2009, 19:36
  4. Replies: 0
    Last Post: 31st May 2009, 16:51
  5. QPaintEvent syntax question
    By last2kn0 in forum Newbie
    Replies: 5
    Last Post: 25th January 2008, 20:36

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.