Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) Qt QStyleSheet

 

QStyleSheet is a Qt class.

 

 

 

 

 

 

Technical facts

 

Application type(s)

Operating system(s) or programming environment(s)

IDE(s):

Project type:

C++ standard:

Compiler(s):

Libraries used:

 

 

 

 

 

Qt project file: CppQStyleSheet.pro

 

QT       += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TEMPLATE = app
SOURCES += main.cpp\
        dialog.cpp
HEADERS  += dialog.h
FORMS    += dialog.ui

 

 

 

 

 

dialog.h

 

#ifndef DIALOG_H
#define DIALOG_H

#include <QDialog>

namespace Ui {
class Dialog;
}

class Dialog : public QDialog
{
    Q_OBJECT
    
public:
    explicit Dialog(QWidget *parent = 0);
    ~Dialog();
    
private slots:
  void on_button_toggle_clicked();

private:
    Ui::Dialog *ui;
};

#endif // DIALOG_H

 

 

 

 

 

dialog.cpp

 

#include "dialog.h"
#include "ui_dialog.h"

Dialog::Dialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::Dialog)
{
    ui->setupUi(this);
}

Dialog::~Dialog()
{
    delete ui;
}

void Dialog::on_button_toggle_clicked()
{
  ui->button_show->setEnabled( ! ui->button_show->isEnabled() );

  ui->button_show->setText(
    ui->button_show->isEnabled()
    ? QString("I am enabled")
    : QString("I am disabled"));
}

 

 

 

 

 

main.cpp

 

#include <QApplication>
#include "dialog.h"

const std::string CreateStyleSheet()
{
  const std::string s =
    "QPushButton:enabled {"
    "  background-color: green;"
    "}"
    "QPushButton:disabled {"
    "  background-color: red;"
    "}";
  return s;
}

int main(int argc, char *argv[])
{
  QApplication a(argc, argv);
  a.setStyleSheet(CreateStyleSheet().c_str());
  Dialog w;
  w.show();

  return a.exec();
}

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict

This page has been created by the tool CodeToHtml

QStyleSheet

Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) QStyleSheet

 

 

 

 

 

 

 

 

 

 

 

Technical facts

 

Application type(s)

Operating system(s) or programming environment(s)

IDE(s):

Project type:

C++ standard:

Compiler(s):

Libraries used:

 

 

 

 

 

Qt project file: CppQStyleSheet.pro

 

QT       += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TEMPLATE = app
SOURCES += main.cpp\
        dialog.cpp
HEADERS  += dialog.h
FORMS    += dialog.ui

 

 

 

 

 

dialog.h

 

#ifndef DIALOG_H
#define DIALOG_H

#include <QDialog>

namespace Ui {
class Dialog;
}

class Dialog : public QDialog
{
    Q_OBJECT
    
public:
    explicit Dialog(QWidget *parent = 0);
    ~Dialog();
    
private slots:
  void on_button_toggle_clicked();

private:
    Ui::Dialog *ui;
};

#endif // DIALOG_H

 

 

 

 

 

dialog.cpp

 

#include "dialog.h"
#include "ui_dialog.h"

Dialog::Dialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::Dialog)
{
    ui->setupUi(this);
}

Dialog::~Dialog()
{
    delete ui;
}

void Dialog::on_button_toggle_clicked()
{
  ui->button_show->setEnabled( ! ui->button_show->isEnabled() );

  ui->button_show->setText(
    ui->button_show->isEnabled()
    ? QString("I am enabled")
    : QString("I am disabled"));
}

 

 

 

 

 

main.cpp

 

#include <QApplication>
#include "dialog.h"

const std::string CreateStyleSheet()
{
  const std::string s =
    "QPushButton:enabled {"
    "  background-color: green;"
    "}"
    "QPushButton:disabled {"
    "  background-color: red;"
    "}";
  return s;
}

int main(int argc, char *argv[])
{
  QApplication a(argc, argv);
  a.setStyleSheet(CreateStyleSheet().c_str());
  Dialog w;
  w.show();

  return a.exec();
}

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict

This page has been created by the tool CodeToHtml

QStyleSheet

Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) QStyleSheet

 

 

 

 

 

 

 

 

 

 

 

Technical facts

 

Application type(s)

Operating system(s) or programming environment(s)

IDE(s):

Project type:

C++ standard:

Compiler(s):

Libraries used:

 

 

 

 

 

Qt project file: CppQStyleSheet.pro

 

QT       += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TEMPLATE = app
SOURCES += main.cpp\
        dialog.cpp
HEADERS  += dialog.h
FORMS    += dialog.ui

 

 

 

 

 

dialog.h

 

#ifndef DIALOG_H
#define DIALOG_H

#include <QDialog>

namespace Ui {
class Dialog;
}

class Dialog : public QDialog
{
    Q_OBJECT
    
public:
    explicit Dialog(QWidget *parent = 0);
    ~Dialog();
    
private slots:
  void on_button_toggle_clicked();

private:
    Ui::Dialog *ui;
};

#endif // DIALOG_H

 

 

 

 

 

dialog.cpp

 

#include "dialog.h"
#include "ui_dialog.h"

Dialog::Dialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::Dialog)
{
    ui->setupUi(this);
}

Dialog::~Dialog()
{
    delete ui;
}

void Dialog::on_button_toggle_clicked()
{
  ui->button_show->setEnabled( ! ui->button_show->isEnabled() );

  ui->button_show->setText(
    ui->button_show->isEnabled()
    ? QString("I am enabled")
    : QString("I am disabled"));
}

 

 

 

 

 

main.cpp

 

#include <QApplication>
#include "dialog.h"

const std::string CreateStyleSheet()
{
  const std::string s =
    "QPushButton:enabled {"
    "  background-color: green;"
    "}"
    "QPushButton:disabled {"
    "  background-color: red;"
    "}";
  return s;
}

int main(int argc, char *argv[])
{
  QApplication a(argc, argv);
  a.setStyleSheet(CreateStyleSheet().c_str());
  Dialog w;
  w.show();

  return a.exec();
}

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict

This page has been created by the tool CodeToHtml

QStyleSheet

Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) QStyleSheet

 

 

 

 

 

 

 

 

 

 

 

Technical facts

 

Application type(s)

Operating system(s) or programming environment(s)

IDE(s):

Project type:

C++ standard:

Compiler(s):

Libraries used:

 

 

 

 

 

Qt project file: CppQStyleSheet.pro

 

QT       += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TEMPLATE = app
SOURCES += main.cpp\
        dialog.cpp
HEADERS  += dialog.h
FORMS    += dialog.ui

 

 

 

 

 

dialog.h

 

#ifndef DIALOG_H
#define DIALOG_H

#include <QDialog>

namespace Ui {
class Dialog;
}

class Dialog : public QDialog
{
    Q_OBJECT
    
public:
    explicit Dialog(QWidget *parent = 0);
    ~Dialog();
    
private slots:
  void on_button_toggle_clicked();

private:
    Ui::Dialog *ui;
};

#endif // DIALOG_H

 

 

 

 

 

dialog.cpp

 

#include "dialog.h"
#include "ui_dialog.h"

Dialog::Dialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::Dialog)
{
    ui->setupUi(this);
}

Dialog::~Dialog()
{
    delete ui;
}

void Dialog::on_button_toggle_clicked()
{
  ui->button_show->setEnabled( ! ui->button_show->isEnabled() );

  ui->button_show->setText(
    ui->button_show->isEnabled()
    ? QString("I am enabled")
    : QString("I am disabled"));
}

 

 

 

 

 

main.cpp

 

#include <QApplication>
#include "dialog.h"

const std::string CreateStyleSheet()
{
  const std::string s =
    "QPushButton:enabled {"
    "  background-color: green;"
    "}"
    "QPushButton:disabled {"
    "  background-color: red;"
    "}";
  return s;
}

int main(int argc, char *argv[])
{
  QApplication a(argc, argv);
  a.setStyleSheet(CreateStyleSheet().c_str());
  Dialog w;
  w.show();

  return a.exec();
}

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict

This page has been created by the tool CodeToHtml

QStyleSheet

Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) QStyleSheet

 

 

 

 

 

 

 

 

 

 

 

Technical facts

 

Application type(s)

Operating system(s) or programming environment(s)

IDE(s):

Project type:

C++ standard:

Compiler(s):

Libraries used:

 

 

 

 

 

Qt project file: CppQStyleSheet.pro

 

QT       += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TEMPLATE = app
SOURCES += main.cpp\
        dialog.cpp
HEADERS  += dialog.h
FORMS    += dialog.ui

 

 

 

 

 

dialog.h

 

#ifndef DIALOG_H
#define DIALOG_H

#include <QDialog>

namespace Ui {
class Dialog;
}

class Dialog : public QDialog
{
    Q_OBJECT
    
public:
    explicit Dialog(QWidget *parent = 0);
    ~Dialog();
    
private slots:
  void on_button_toggle_clicked();

private:
    Ui::Dialog *ui;
};

#endif // DIALOG_H

 

 

 

 

 

dialog.cpp

 

#include "dialog.h"
#include "ui_dialog.h"

Dialog::Dialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::Dialog)
{
    ui->setupUi(this);
}

Dialog::~Dialog()
{
    delete ui;
}

void Dialog::on_button_toggle_clicked()
{
  ui->button_show->setEnabled( ! ui->button_show->isEnabled() );

  ui->button_show->setText(
    ui->button_show->isEnabled()
    ? QString("I am enabled")
    : QString("I am disabled"));
}

 

 

 

 

 

main.cpp

 

#include <QApplication>
#include "dialog.h"

const std::string CreateStyleSheet()
{
  const std::string s =
    "QPushButton:enabled {"
    "  background-color: green;"
    "}"
    "QPushButton:disabled {"
    "  background-color: red;"
    "}";
  return s;
}

int main(int argc, char *argv[])
{
  QApplication a(argc, argv);
  a.setStyleSheet(CreateStyleSheet().c_str());
  Dialog w;
  w.show();

  return a.exec();
}

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict

This page has been created by the tool CodeToHtml