Results 1 to 6 of 6

Thread: QPushButton::drawButtonLabel problem

  1. #1
    Join Date
    Jun 2008
    Posts
    64
    Thanks
    7
    Qt products
    Qt3 Qt4

    Default QPushButton::drawButtonLabel problem

    I am now porting codes from QT3 to QT4
    And I found that in QT3, QPushButton has a virtual protected member drawButtonLabel which is inherited from QButton.
    void QButton::drawButtonLabel ( QPainter * ) [virtual protected]
    However I can't find any related member in QT 4............
    Can anyone help me with this?

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

    Default Re: QPushButton::drawButtonLabel problem

    What do you need it for? Qt4 does it through use of QStyle::drawControl() with CE_PushButtonLabel

  3. #3
    Join Date
    Jun 2008
    Posts
    64
    Thanks
    7
    Qt products
    Qt3 Qt4

    Default Re: QPushButton::drawButtonLabel problem

    Actually I used this function to do the word wrap on QButton in QT3.
    Since this drawButtonLabel is virtual and we used this to do the word wrap reimplementation.

    However after porting to QT4, I found that the text on QButton is no longer wrapped.
    So what should I so?

  4. #4
    Join Date
    Jun 2008
    Posts
    64
    Thanks
    7
    Qt products
    Qt3 Qt4

    Default Re: QPushButton::drawButtonLabel problem

    Since I m porting old code to QT4.
    and the original code made use of the virtual function `drawButtonLabel` to draw the text and did the word wrapping there.
    So I m looking for something similar to complete the task......

    can anyone help me please???

  5. #5
    Join Date
    Sep 2007
    Location
    Rome, GA
    Posts
    199
    Thanks
    14
    Thanked 41 Times in 35 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: QPushButton::drawButtonLabel problem

    Why can't you just use QPushButton::setText(const QString & text); ? If all you want to do is draw label text, that's what it's for. But if not, maybe this can work....

    Say you override the QPushButton's paint event, then you can call QFontMetrics::boundingRect(const QRect & rect, int flags, const QString & text, int tabStops = 0, int * tabArray = 0 ) ;

    Set Qt::TextWordWrap as a flag, and pass in the text you want to draw as well as the button's rect, and it will return you a QRect you can use to draw your text (with word wrap) in that space. Then you draw it with QPainter::drawText(const QRect & rectangle, int flags, const QString & text, QRect * boundingRect = 0);

    Or maybe you can use style sheets. I'm not too familiar with them myself, but they seem pretty versatile.

  6. #6
    Join Date
    Jun 2008
    Posts
    64
    Thanks
    7
    Qt products
    Qt3 Qt4

    Default Re: QPushButton::drawButtonLabel problem

    actually I m doing something similar in the virtual function.............
    Since the `drawButtonLabel` should be invoked automatically, that's why I needa find something alike to invoke the process

Similar Threads

  1. problem with paint and erase in frame
    By M.A.M in forum Qt Programming
    Replies: 9
    Last Post: 4th May 2008, 20:17
  2. PyQt QTimer problem { FIXED }
    By WinchellChung in forum Newbie
    Replies: 0
    Last Post: 1st March 2008, 16:50
  3. Tricky problem with ARGB widget / UpdateLayeredWindow
    By nooky59 in forum Qt Programming
    Replies: 3
    Last Post: 21st February 2008, 10:35
  4. Graphics view display problem.
    By kiranraj in forum Qt Programming
    Replies: 3
    Last Post: 20th July 2007, 07:08
  5. Replies: 16
    Last Post: 7th March 2006, 15:57

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.