Page 1 of 2 12 LastLast
Results 1 to 20 of 22

Thread: problem of opacity for textLabel

  1. #1
    Join Date
    Apr 2006
    Posts
    21
    Thanks
    6

    Default problem of opacity for textLabel

    Hello!

    I ve an text Label with palette backgrounColor(default set the palette of parent)

    I would like have a Label with not Color Font(tital opacity)




    thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Ukraine,Lviv
    Posts
    454
    Thanks
    9
    Thanked 27 Times in 27 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: problem of opacity for textLabel

    Hm..can you give us extended explain?
    Are you mean set foreground color for label?
    As i know you can set opacity only for widget not for fonts
    Also tell what version of Qt you use
    a life without programming is like an empty bottle

  3. #3
    Join Date
    Apr 2006
    Posts
    21
    Thanks
    6

    Default Re: problem of opacity for textLabel

    hello

    yes ,sure ,i mean foregroundColor of widget.
    but the pb is palettebackgrouncolor:
    So,opacity is for "font "not for widget(String)
    then I would like have a widget label with total opacity of Font (or backgrpoundcolor).

    Thanks

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: problem of opacity for textLabel

    Huh... I might be misunderstanding the half of what you are trying to say, but...

    Qt Code:
    1. QColor color(Qt::yellow);
    2. color.setAlpha(150); // set alpha level for text color (0-255)
    3. QPalette pal = label->palette();
    4. if (label->textFormat() == Qt::RichText)
    5. pal.setColor(QPalette::Text, color); // if using rich text
    6. else
    7. pal.setColor(label.foregroundRole(), color); // otherwise if not using rich text
    8. label->setPalette(pal);
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  5. The following 2 users say thank you to jpn for this useful post:

    FireMan (14th June 2008), Stephano (10th May 2006)

  6. #5
    Join Date
    Apr 2006
    Posts
    21
    Thanks
    6

    Default Re: problem of opacity for textLabel

    Hello!

    Thanks very match for your response.
    Qt3 has not the method setAlpha:this is a problem!
    So,
    my code is:
    void SAG_Text::SAG_text_afficher()
    {
    QRgb rgb,rgb1;
    this->setGeometry(*text_rectangle);

    rgb1=text_state.Text_IDLE.Font_Color;
    QColor color1=QColor(rgb1,0xffffffff);
    this->setPaletteForegroundColor(color1);
    //this->setPaletteForegroundColor(*text_color_contents) ;

    this->setFont(*text_font);
    this->setText(*text_contents);
    if(opacity==TRUE)
    {
    rgb=text_state.Text_IDLE.Background_Color;
    QColor color=QColor(rgb,0xffffffff);
    this->setPaletteBackgroundColor(color);

    }
    else
    {
    QPainter *p=new QPainter();
    p->setBackgroundMode( Qt::TransparentMode );
    this->drawFrame(p);
    }
    this->show();
    }


    But ,no result!
    Last edited by Stephano; 10th May 2006 at 09:51.

  7. #6
    Join Date
    Apr 2006
    Posts
    21
    Thanks
    6

    Default Problem of transparence of text(QLabel)

    i would like have a text transparentTransparence of cadre of text,not of contents)the user of my application can choose between 2 choice:
    • transparent
    • opaque


    So , qt 4 can resolve the pb with Qcolor.setAlpha(..);
    But ,i have many pb of installation of Qt4.

    then ,how can i ,for exemple ,use Qpainter (paintEvent...) to define a transparence.
    If there are other solutions or explications, help me ,please!
    My regards!

  8. #7
    Join Date
    Apr 2006
    Posts
    21
    Thanks
    6

    Default Text (QLabel) transparent

    i would like have a text transparent :
    Transparence of cadre of text,not of contents)
    the user of my application can choose between 2 choice:
    transparent
    opaque


    So , qt 4 can resolve the pb with Qcolor.setAlpha(..);
    But ,i have many pb of installation of Qt4.

    then ,how can i ,for exemple ,use Qpainter (paintEvent...) to define a transparence.
    If there are other solutions or explications, help me ,please!
    My regards!

  9. #8
    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: Text (QLabel) transparent

    Please, do not start multiple threads on the same subject! This is fourth or fifth thread you start about the same thing. Please use a single thread which is opened for discussion!

  10. #9
    Join Date
    Apr 2006
    Posts
    21
    Thanks
    6

    Default QLabel with backgoundColor transparent!

    hello!

    i wouls like draw a Qlabel.
    i need choose between :
    tansparence or no!

    the pb is qthas not setAlpha!
    so, how can i use Qpainter for exemple ,to have a backgroundColor of text transparent
    .It s urgency!

    Thanks!!!!

  11. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QLabel with backgoundColor transparent!

    Please, don't start multiple threads on the same problem or else...

  12. #11
    Join Date
    Apr 2006
    Posts
    21
    Thanks
    6

    Default Re: QLabel with backgoundColor transparent!

    Sorry Mr.jacek ,
    but it s very urgent!
    Can u help me?

  13. #12
    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: problem of opacity for textLabel

    What about jpn's answer?

  14. #13
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QLabel with backgoundColor transparent!

    Quote Originally Posted by Stephano
    but it s very urgent!
    There are no urgent matters --- this is a community forum. People answer questions in their free time.

    Can u help me?
    What exactly do you want to achieve? What is under the label?

    One of the QQ articles suggests three solutions:
    We need a different approach if we want the parent widget's background to shine through. [...] In Qt 3, there are several ways to simulate this feature:
    • You can use QPainter::redirect() and then call the parent widget's paintEvent() to have the parent draw itself onto the widget's background directly.
    • You can set a transparency mask (QWidget::setMask()). The parent widget is aware of the child widget's mask and will paint all areas not covered by the mask.
    • If the parent doesn't paint anything underneath the child widget other than its background, you can fill the child widget's background by inheriting the parent widget's brush and applying a suitable offset by calling QWidget::setBackgroundOrigin().

  15. The following user says thank you to jacek for this useful post:

    Stephano (17th May 2006)

  16. #14
    Join Date
    Apr 2006
    Posts
    21
    Thanks
    6

    Default Re: problem of opacity for textLabel

    thanks!very match

  17. #15
    Join Date
    Apr 2006
    Posts
    21
    Thanks
    6

    Default Re: problem of opacity for textLabel

    i would like a tewt Label
    witch contents only the string
    So the cadre of label must be transparent
    Because the text will be draw in the bitmap(no backgroun color)
    thanks

  18. #16
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: problem of opacity for textLabel

    Quote Originally Posted by Stephano
    Because the text will be draw in the bitmap(no backgroun color)
    Is that bitmap the background of your window or is it displayed by some widget (for example a QLabel)?

    You might try to reimplement the paintEvent() for your widget and draw that text there.

  19. #17
    Join Date
    Apr 2006
    Posts
    21
    Thanks
    6

    Default Re: problem of opacity for textLabel

    i would like draw only the String of Qlabel
    So ,how i implemente
    paintEvent()
    please?
    can u give me an exemple!

  20. #18
    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: problem of opacity for textLabel

    Have you tried simply using QWidget::backgroundOrigin property? If you assign both your label and its parent the same bitmap as a background, it should be possible to blend them together.

  21. The following user says thank you to wysota for this useful post:

    Stephano (18th May 2006)

  22. #19
    Join Date
    Apr 2006
    Posts
    21
    Thanks
    6

    Default Re: problem of opacity for textLabel

    thanks
    but,
    to set the color of parent dont resolve the problem.
    i neded a realy transparent label in my application

  23. #20
    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: problem of opacity for textLabel

    What for? Maybe you could explain what do you intend to do with it.

Similar Threads

  1. Weird problem: multithread QT app kills my linux
    By Ishark in forum Qt Programming
    Replies: 2
    Last Post: 8th August 2008, 09:12
  2. Steps in solving a programming problem?
    By triperzonak in forum General Programming
    Replies: 8
    Last Post: 5th August 2008, 08:47
  3. 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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.