Results 1 to 6 of 6

Thread: Declaring two constructor

  1. #1
    Join Date
    Jun 2011
    Location
    Porto Alegre, Brazil
    Posts
    482
    Thanks
    165
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Declaring two constructor

    Hello!

    When I learned C++ I learned that when constructing a class one could create more than one constructor function for that class. In fact, we see this in various of the Qt's own classes.

    But the problem is that I'm being unable to do the same in my classes; Qt simply don't accept it.

    Could somebody please provide me with an example of how can I put two or more constructor functions in one class in Qt?

    Thanks!


    Momergil

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Declaring two constructor

    But the problem is that I'm being unable to do the same in my classes; Qt simply don't accept it.
    Post your code.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Jun 2011
    Location
    Porto Alegre, Brazil
    Posts
    482
    Thanks
    165
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Declaring two constructor

    \o/

    now that I was going to post my example I noticed it's working ¬¬"

    I don't know why, anyway. I guess I learned how to do it.


    Thanks.

  4. #4
    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: Declaring two constructor

    Quote Originally Posted by Momergil View Post
    But the problem is that I'm being unable to do the same in my classes; Qt simply don't accept it.
    Could somebody please provide me with an example of how can I put two or more constructor functions in one class in Qt?
    This has nothing to do with Qt. This is between you and C++.

  5. #5
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Thanks
    3
    Thanked 106 Times in 103 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Declaring two constructor

    Quote Originally Posted by Momergil View Post
    \o/
    I don't know why, anyway. I guess I learned how to do it.
    So you don't know how you know? How you know then that you know?

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Declaring two constructor

    He knows he doesn't know. He just learned that he didn't know, you know.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Declaring Other Libraries - Linux
    By brenno in forum Qt Programming
    Replies: 2
    Last Post: 24th January 2012, 14:34
  2. declaring subclasses in C++
    By Paat in forum Newbie
    Replies: 4
    Last Post: 23rd October 2009, 08:40
  3. problem in declaring QDirModel
    By prasanth.nvs in forum Qt for Embedded and Mobile
    Replies: 3
    Last Post: 11th December 2008, 16:45
  4. Error declaring Qt object
    By Doug Broadwell in forum Qt Programming
    Replies: 3
    Last Post: 9th September 2007, 21:15
  5. declaring a friend
    By jayw710 in forum Qt Tools
    Replies: 2
    Last Post: 18th April 2006, 04:12

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.