Results 1 to 7 of 7

Thread: subclass qpushbutton

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2012
    Posts
    57
    Thanks
    11
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default subclass qpushbutton

    I want to subclass QPushButton

    Qt Code:
    1. somefile.h
    2. //--------------------------------------
    3. class Button : public QPushButton
    4. {
    5. Q_OBJECT
    6. public:
    7. Button(QWidget *parent);
    8. Button(const QString &text, QWidget *parent);
    9. };
    10.  
    11. somefile.cpp
    12. /*------------------------------------------------------------------------------------*/
    13. Button::Button(const QString & text, QWidget * parent = 0 )
    14. {
    15. this->setText(text);
    16. }
    17. /*------------------------------------------------------------------------------------*/
    18. Button::Button(QWidget *parent) : QPushButton(parent)
    19. {
    20. }
    To copy to clipboard, switch view to plain text mode 

    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?
    If I call them with okButton = new Button(QString("ok")); I also get the error because of the missing parent.
    I'm obviously new at this.
    Thanks.
    Last edited by Cremers; 22nd June 2013 at 18:52.

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.