Results 1 to 7 of 7

Thread: subclass qpushbutton

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    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: subclass qpushbutton

    Quote Originally Posted by Cremers View Post
    However, I get 'no matching function for call to char[]' errors on code that calls them like this: okButton = new Button("Ok");
    How is this done, it should convert the char[] somehow to const QString?
    Your class expects a QString and is being given a const char*. The compiler will try to find a QString constructor accepting a const char*, a conversion constructor, and construct a QString on your behalf. If there is no such constructor then your code generates an error like the one you describe. If your program is being built with QT_NO_CAST_FROM_ASCII defined then QString interfaces accepting C string literals are disabled and you need to explicitly do something like this:
    Qt Code:
    1. Button b(QLatin1String("coffee"));
    2. //or
    3. Button b(QString::fromUtf8("кофе"));
    To copy to clipboard, switch view to plain text mode 

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

    Cremers (23rd June 2013)

Similar Threads

  1. Subclass QList<T>
    By Seishin in forum Qt Programming
    Replies: 4
    Last Post: 23rd April 2013, 23:22
  2. Replies: 2
    Last Post: 15th April 2013, 06:33
  3. Replies: 8
    Last Post: 12th February 2010, 02:41
  4. Subclass
    By merry in forum General Programming
    Replies: 2
    Last Post: 1st March 2007, 10:34
  5. Reg - Subclass of QListBoxItem
    By lawrence in forum Newbie
    Replies: 1
    Last Post: 6th January 2007, 14:18

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.