Solved

Set Background in Main Window only using QT

Posted on 2010-11-11
5
3,817 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to install eclipse SCADA on Linux Debian? 4 165
netbeans not showing web project 3 102
regex. How to include lines between 10 99
I could not build boost code, 10 114
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. …
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 use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…

738 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