Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8448037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:19:20+00:00 2026-06-10T10:19:20+00:00

I have subclassed QLabel as follows: class TestLabel: public QLabel { Q_OBJECT public: TestLabel(QWidget

  • 0

I have subclassed QLabel as follows:

class TestLabel: public QLabel
{
    Q_OBJECT
public:
    TestLabel(QWidget *parent = 0):QLabel(parent){}
    TestLabel(const QString& text, QWidget *parent = 0):QLabel(text, parent){}

protected:
    void paintEvent(QPaintEvent *paint)
     {
         QStyleOption opt;
         opt.init(this);
         QPainter p(this);
         style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
         style()->drawItemText(&p,this->rect(),Qt::AlignLeft, (this->palette()), true, this->text());

     }
};

I have setup the stylesheet as follows:

TestLabel {
    font-size: 16px;
    color: rgb(127, 127, 127);
}

I am trying to wrap text by using: tlab->setWordWrap(true);
Before overriding paintEvent, the text was being wrapped properly. But now, the text is no longer wrapped. The documentation says that the “The text is aligned and wrapped according to flags.”, but how do I pass in both flags(both of them are distinct enums)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T10:19:21+00:00Added an answer on June 10, 2026 at 10:19 am

    OK. I got the answer. I was looking at the wrong class. I was looking at QTextOption::WordWrap.

    I needed to use Qt::TextWordWrap as Qt::AlignLeft | Qt::TextWordWrap

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have subclassed NSMutableArray as follows: Base Class: @interface MyBaseMutableArray : NSMutableArray { //
I have subclassed a control in C# WinForms, and am custom drawing text in
I have subclassed UIViewController into a new class, PageViewController (I'm writing a simple book
We have subclassed the Silverlight Application class to add some additional functionality and then
I have subclassed a UITableViewCell and within this class I want to get it's
I have subclassed UITableViewCell for a custom cell view along the lines as follows:
I have a custom PDFDocument class where I have subclassed - (Class)pageClass and return
I have subclassed a system class (UINavigationBar, to be specific) to add some specific
I'm trying to draw some circle overlays containing text on MKMapView. I have subclassed
I have subclassed Process like so: class EdgeRenderer(Process): def __init__(self,starter,*args,**kwargs): Process.__init__(self,*args,**kwargs) self.starter=starter Then I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.