Solved

Set Background in Main Window only using QT

Posted on 2010-11-11
5
3,502 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org Go to that link and select download selenium in the right hand columnThat will then direct you to their download page.From that page s…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

910 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

21 Experts available now in Live!

Get 1:1 Help Now