Solved

Set Background in Main Window only using QT

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
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.
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.

726 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