Results 1 to 6 of 6

Thread: A doubt about initialization of variables

  1. #1
    Join Date
    Jul 2007
    Location
    Jundiai/SP, Brazil
    Posts
    114
    Thanks
    5
    Thanked 7 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question A doubt about initialization of variables

    Hi,

    When I initialize a variable of this way:
    Qt Code:
    To copy to clipboard, switch view to plain text mode 
    or
    Qt Code:
    To copy to clipboard, switch view to plain text mode 
    what exactly accours? What value is assigned to the variable?

    Thanks in advanced

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: A doubt about initialization of variables

    in the first example an empty string in the second an empty list.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. #3
    Join Date
    Jul 2007
    Location
    Jundiai/SP, Brazil
    Posts
    114
    Thanks
    5
    Thanked 7 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: A doubt about initialization of variables

    Thanks spirit.

  4. #4
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: A doubt about initialization of variables

    You'll also notice this in the documentation.

    QString::QString ()
    Constructs a null string. Null strings are also empty.

    QStringList::QStringList ()
    Constructs an empty string list.

  5. #5
    Join Date
    Feb 2007
    Location
    Karlsruhe, Germany
    Posts
    469
    Thanks
    17
    Thanked 90 Times in 88 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: A doubt about initialization of variables

    and those default constructors are called here as well, without any superficial assignment operation...

    Qt Code:
    1. QString str;
    To copy to clipboard, switch view to plain text mode 

    You can call some other constructor than the default constructor like this:

    Qt Code:
    1. QString str("yep");
    2. QStringList sl(str);
    To copy to clipboard, switch view to plain text mode 

    HIH

    Johannes

  6. #6
    Join Date
    Jul 2007
    Location
    Jundiai/SP, Brazil
    Posts
    114
    Thanks
    5
    Thanked 7 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: A doubt about initialization of variables

    Hi people,

    Thanks by all answers.

Similar Threads

  1. QDevelop debuggng - viewing class member variables
    By dbrmik in forum Qt-based Software
    Replies: 0
    Last Post: 7th January 2009, 10:40
  2. creating query string from variables
    By locus in forum General Programming
    Replies: 2
    Last Post: 16th April 2007, 08:50

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.