Created
August 26, 2014 21:11
-
-
Save ynonp/6e1720d00ae315c25efb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#------------------------------------------------- | |
# | |
# Project created by QtCreator 2014-08-26T10:07:27 | |
# | |
#------------------------------------------------- | |
QT += core gui | |
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets | |
TARGET = HelloWorld | |
TEMPLATE = app | |
SOURCES += main.cpp\ | |
mainwindow.cpp | |
HEADERS += mainwindow.h | |
FORMS += mainwindow.ui |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "mainwindow.h" | |
#include <QApplication> | |
int main(int argc, char *argv[]) | |
{ | |
QApplication a(argc, argv); | |
MainWindow w; | |
w.show(); | |
return a.exec(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "mainwindow.h" | |
#include "ui_mainwindow.h" | |
MainWindow::MainWindow(QWidget *parent) : | |
QMainWindow(parent), | |
ui(new Ui::MainWindow) | |
{ | |
ui->setupUi(this); | |
QObject::connect(ui->pushButton, SIGNAL(clicked()), | |
this, SLOT(changeText())); | |
} | |
MainWindow::~MainWindow() | |
{ | |
delete ui; | |
} | |
void MainWindow::changeText() | |
{ | |
ui->label->setText("Hello World!"); | |
ui->label->setProperty("clicked", true); | |
updateStylesheet(ui->label); | |
} | |
void MainWindow::updateStylesheet(QWidget *widget) | |
{ | |
widget->style()->unpolish(widget); | |
widget->style()->polish(widget); | |
widget->update(); | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef MAINWINDOW_H | |
#define MAINWINDOW_H | |
#include <QMainWindow> | |
namespace Ui { | |
class MainWindow; | |
} | |
class MainWindow : public QMainWindow | |
{ | |
Q_OBJECT | |
public: | |
explicit MainWindow(QWidget *parent = 0); | |
~MainWindow(); | |
public slots: | |
void changeText(); | |
private: | |
void updateStylesheet(QWidget *widget); | |
private: | |
Ui::MainWindow *ui; | |
}; | |
#endif // MAINWINDOW_H |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<ui version="4.0"> | |
<class>MainWindow</class> | |
<widget class="QMainWindow" name="MainWindow"> | |
<property name="geometry"> | |
<rect> | |
<x>0</x> | |
<y>0</y> | |
<width>400</width> | |
<height>300</height> | |
</rect> | |
</property> | |
<property name="windowTitle"> | |
<string>MainWindow</string> | |
</property> | |
<property name="styleSheet"> | |
<string notr="true">QPushButton { | |
color: blue; | |
} | |
QLabel { | |
color: green; | |
} | |
QLabel[clicked="true"] { | |
color: red; | |
} | |
s</string> | |
</property> | |
<widget class="QWidget" name="centralWidget"> | |
<layout class="QHBoxLayout" name="horizontalLayout"> | |
<item> | |
<layout class="QVBoxLayout" name="verticalLayout"> | |
<item> | |
<widget class="QLabel" name="label"> | |
<property name="font"> | |
<font> | |
<family>Geeza Pro</family> | |
</font> | |
</property> | |
<property name="styleSheet"> | |
<string notr="true"/> | |
</property> | |
<property name="text"> | |
<string>please click the button</string> | |
</property> | |
</widget> | |
</item> | |
<item> | |
<widget class="QPushButton" name="pushButton"> | |
<property name="styleSheet"> | |
<string notr="true"/> | |
</property> | |
<property name="text"> | |
<string>Click me</string> | |
</property> | |
</widget> | |
</item> | |
<item> | |
<widget class="QPushButton" name="pushButton_2"> | |
<property name="autoFillBackground"> | |
<bool>true</bool> | |
</property> | |
<property name="styleSheet"> | |
<string notr="true"/> | |
</property> | |
<property name="text"> | |
<string>No no click me</string> | |
</property> | |
</widget> | |
</item> | |
</layout> | |
</item> | |
<item> | |
<widget class="QListWidget" name="listWidget"> | |
<item> | |
<property name="text"> | |
<string>red</string> | |
</property> | |
</item> | |
<item> | |
<property name="text"> | |
<string>blue</string> | |
</property> | |
</item> | |
<item> | |
<property name="text"> | |
<string>green</string> | |
</property> | |
</item> | |
<item> | |
<property name="text"> | |
<string>yellow</string> | |
</property> | |
</item> | |
</widget> | |
</item> | |
</layout> | |
</widget> | |
<widget class="QMenuBar" name="menuBar"> | |
<property name="geometry"> | |
<rect> | |
<x>0</x> | |
<y>0</y> | |
<width>400</width> | |
<height>22</height> | |
</rect> | |
</property> | |
</widget> | |
<widget class="QToolBar" name="mainToolBar"> | |
<attribute name="toolBarArea"> | |
<enum>TopToolBarArea</enum> | |
</attribute> | |
<attribute name="toolBarBreak"> | |
<bool>false</bool> | |
</attribute> | |
</widget> | |
<widget class="QStatusBar" name="statusBar"/> | |
</widget> | |
<layoutdefault spacing="6" margin="11"/> | |
<resources/> | |
<connections/> | |
</ui> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment