Results 1 to 4 of 4

Thread: Hi everyone

  1. #1
    Join Date
    Mar 2007
    Posts
    16
    Thanks
    9
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Red face Hi everyone

    i have two questions:
    first how can i apply html text formatting to a string variable , i mean i have some thing like this
    titreLabel = new QLabel("<font color= 'green' size = 15><b>Welcome</b></font>" + surname + " " + name, this);

    my formating applies only to welcome but i dont know how i can apply the same formatting the strings contained in my two variables surname and name... cause if i put then between " " they will not be considered as variables..

    the second question is that how can i put an image on the background of a widget

    tnx for ur help...

  2. #2
    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: Hi everyone

    Quote Originally Posted by Ahmad View Post
    my formating applies only to welcome but i dont know how i can apply the same formatting the strings contained in my two variables surname and name... cause if i put then between " " they will not be considered as variables..
    Qt Code:
    1. titreLabel = new QLabel(
    2. QString("<font color= 'green' size = "15"><b>Welcome %1 %2").arg(surname).arg(name),
    3. this);
    To copy to clipboard, switch view to plain text mode 

    the second question is that how can i put an image on the background of a widget
    Set the image as a brush for the background role of your widget's palette.

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

    Ahmad (31st May 2007)

  4. #3
    Join Date
    Mar 2007
    Posts
    16
    Thanks
    9
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Hi everyone

    QPalette palette;
    palette->setBrush(QPalette::Background,QBrush(Qt::blue,Qt: :SolidPattern));
    this->setPalette(palette);

    i have written this, but i see just a blue sceen splashes and then disappears, i dont really know how to set my background color that should not disappear

  5. #4
    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: Hi everyone

    First of all don't create a new palette but fetch it from the widget you are changing. Second of all, maybe you used the incorrect role for the widget (what widget is that?), third of all, if you're styling a custom widget, it might not support using a palette to paint its background.

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.