Solved

Set Background in Main Window only using QT

Posted on 2010-11-11
5
3,377 Views
Last Modified: 2013-11-23
I am new to QT and am trying to set the background for the main window without the child widgets being affected.

I am using QT creator and the GUI and the way I have found so far is to right click on the form, Choose "change stylesheet" and set the background url.

However this affects all widgets on the form giving them the same background.

How do I avoid this?
0
Comment
Question by:dbdp
  • 3
  • 2
5 Comments
 
LVL 7

Accepted Solution

by:
irfan_omair earned 500 total points
ID: 34117817
you can try this

QPalette pal = a->palette();
pal.setColor(QPalette::Window, Qt::white);
myWindow->setPalette(pal);

Or you can also do it using Stylesheet in your code

MainWindow::MainWindow(QWidget *parent) : QWidget(parent), ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    this->setStyleSheet("background-color: black;");
}


Let me know if you still unable to do it

regards,
Irfan Omair
0
 

Author Comment

by:dbdp
ID: 34120615
My Mistake, My problem is that when I set a background image it propagates to all the widgets on the form
0
 
LVL 7

Expert Comment

by:irfan_omair
ID: 34121356
Hey wait, Are you trying to set background image on the main window or background color??
0
 

Author Comment

by:dbdp
ID: 34122017
Background image - but I want to limit it to main window only!
0
 
LVL 7

Expert Comment

by:irfan_omair
ID: 34234789
dbdp:
Sorry I was on vacation.
are you still having this problem?
If not can you have look of the license wizard example which is available in Qt Demos and Example.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

In our object-oriented world the class is a minimal unit, a brick for constructing our applications. It is an abstraction and we know well how to use it. In well-designed software we are not usually interested in knowing how objects look in memory. …
Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now