+ Reply to Thread
Results 1 to 4 of 4

Thread: How to overcome the shade of the label in the background image?

  1. #1
    Join Date
    Nov 2011
    Posts
    45
    Qt products
    Qt4
    Platforms
    Symbian S60

    Post How to overcome the shade of the label in the background image?

    Hi All,
    I had attached a picture in which i have set the background and also kept two labels in it.
    The Problem i have is the label border is above the background image and looks like a block in front.
    I have to hide the border and only the wordings should alone be displayed!!!


    Can anyone help me in finding a solution will be highly appreciated!!!


    Thanks in advance and Regards, hdsdfh.jpg

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    6,430
    Thanks
    13
    Thanked 1,357 Times in 1,299 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How to overcome the shade of the label in the background image?

    How did you apply the background?

  3. #3
    Join Date
    Nov 2011
    Posts
    45
    Qt products
    Qt4
    Platforms
    Symbian S60

    Default Re: How to overcome the shade of the label in the background image?

    I had done it with UI design and not through codewise.

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    6,430
    Thanks
    13
    Thanked 1,357 Times in 1,299 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How to overcome the shade of the label in the background image?

    You need to be more specific about what widgets will have the background applied. At the moment you are probably setting a background on the main widget and this cascades to all widgets placed on it.

    Qt Code:
    1. #include <QtGui>
    2. #include <QDebug>
    3.  
    4. class MainWindow: public QMainWindow {
    5. Q_OBJECT
    6. public:
    7. MainWindow(QWidget *p = 0): QMainWindow(p) {
    8. QWidget *central = new QWidget(this);
    9. central->setObjectName("centralWidget");
    10. // this
    11. central->setStyleSheet("#centralWidget { background: url('gradient.png'); }" );
    12. // not this
    13. // central->setStyleSheet("* { background: url('gradient.png'); }" );
    14.  
    15.  
    16. QVBoxLayout *layout = new QVBoxLayout(central);
    17. QLabel *label1 = new QLabel("Label 1", this);
    18. QLabel *label2 = new QLabel("Label 2", this);
    19.  
    20. layout->addWidget(label1);
    21. layout->addWidget(label2);
    22.  
    23. central->setLayout(layout);
    24. setCentralWidget(central);
    25. }
    26. public slots:
    27. private:
    28. };
    29.  
    30. int main(int argc, char *argv[])
    31. {
    32. QApplication app(argc, argv);
    33.  
    34. MainWindow m;
    35. m.show();
    36. return app.exec();
    37. }
    38. #include "main.moc"
    To copy to clipboard, switch view to plain text mode 

+ Reply to Thread

Similar Threads

  1. how to draw background color of a label
    By gauravg in forum Qt Programming
    Replies: 1
    Last Post: 1st November 2011, 03:46
  2. Shade in background?
    By Niamita in forum Qt Programming
    Replies: 3
    Last Post: 29th June 2011, 11:22
  3. Replies: 0
    Last Post: 5th April 2011, 13:36
  4. How to make a label be on the background?
    By Bong.Da.City in forum Newbie
    Replies: 3
    Last Post: 6th September 2010, 11:37
  5. Replies: 5
    Last Post: 16th December 2009, 11:33

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