Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
walking98 committed Mar 26, 2020
0 parents commit f43afea
Show file tree
Hide file tree
Showing 24 changed files with 453 additions and 0 deletions.
19 changes: 19 additions & 0 deletions mainwindow.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include "mainwindow.h"
#include "ui_mainwindow.h"

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

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

void MainWindow::on_pushButton_clicked()
{
ui->textEdit->append( "Hello World!");
}
47 changes: 47 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# C++ objects and libs
*.slo
*.lo
*.o
*.a
*.la
*.lai
*.so
*.dll
*.deb
*.dylib

# Qt-es
object_script.*.Release
object_script.*.Debug
*_plugin_import.cpp
/.qmake.cache
/.qmake.stash
*.pro.user
*.pro.user.*
*.qbs.user
*.qbs.user.*
*.moc
moc_*.cpp
moc_*.h
qrc_*.cpp
ui_*.h
*.qmlc
*.jsc
Makefile*
*build-*

# Qt unit tests
target_wrapper.*

# QtCreator
*.autosave

# QtCreator Qml
*.qmlproject.user
*.qmlproject.user.*

# QtCreator CMake
CMakeLists.txt.user*
build
target
.flatpak-builder
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM tefworkshop/qt5-gui

MAINTAINER cetc15

#RUN apt-get update && apt-get install -y apt-utils sudo
USER root

COPY . /home/HelloWorldGui
RUN tar xvf /home/HelloWorldGui/lib.tar -C /usr
WORKDIR /home/HelloWorldGui
RUN qmake HelloWorldGui.pro; make
RUN chmod +x /home/HelloWorldGui/HelloWorldGui; ls /home/HelloWorldGui/

CMD /home/HelloWorldGui/HelloWorldGui

19 changes: 19 additions & 0 deletions HelloWorldGui.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
QT += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = HelloWorldGui
TEMPLATE = app


SOURCES += main.cpp\
mainwindow.cpp

HEADERS += mainwindow.h

FORMS += mainwindow.ui
## Added by IDE : mylib
EXT_LIBS += -lmylib
## Added by IDE : mylib-ext
EXT_LIBS += -lmylibExt
LIBS += $${EXT_LIBS}
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
## GUI应用说明

1. 这是使用QTCreator创建的一个图形界面程序

2. 程序中通过qt-plugin插件,引入了两个commLib: mylib, mylibExt

3. 你可以使用docker方式构成镜像,来运行

4. 生成镜像后可以使用如下的脚本,来运行图形化界面
```
# 在宿主机器执行下面的命令,安装x11配置
sudo apt-get install x11-xserver-utils
xhost +
# 然后运行docker镜像
docker run -d \
-v /etc/localtime:/etc/localtime:ro \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-d \
-e LANG=C.UTF-8 \
-e DISPLAY=unix$DISPLAY \
-e GDK_SCALE \
-e GDK_DPI_SCALE \
--name <命名容器名> \
<镜像名字>
```
9 changes: 9 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
cd /app/SRC
# apt install free
tar xvf lib.tar -C /usr
qmake HelloWorldGui.pro
make
mkdir -p /app/bin/
ls HelloWorldGui
cp HelloWorldGui /app/bin/runApp
chmod +x /app/bin/runApp
2 changes: 2 additions & 0 deletions debian/gen.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dpkg -b mylib mylib.deb
dpkg -b mylib-ext mylib-ext.deb
12 changes: 12 additions & 0 deletions debian/mylib-ext/DEBIAN/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Package: mylib-ext
Version: 1.0
Architecture: amd64
Maintainer: Kevin Wang
Installed-Size: 128
Recommends:
Suggests:
Section: devel
Priority: optional
Multi-Arch: foreign
Depends: mylib
Description: just for test
1 change: 1 addition & 0 deletions debian/mylib-ext/DEBIAN/postinst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#包含了软件在进行正常目录文件拷贝到系统后,所需要执行的配置工作
1 change: 1 addition & 0 deletions debian/mylib-ext/DEBIAN/postrm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#软件卸载后需要执行的脚本
1 change: 1 addition & 0 deletions debian/mylib-ext/DEBIAN/prerm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#软件卸载前需要执行的脚本
16 changes: 16 additions & 0 deletions debian/mylib-ext/usr/include/mylibext.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#ifndef MYLIBEXT_H
#define MYLIBEXT_H

#include <string>

using std::string;

class MyLibExt
{
public:
MyLibExt();
string sayHello(const char* name);
string sayHelloExt(const char* name);
};

#endif // MYLIBEXT_H
11 changes: 11 additions & 0 deletions debian/mylib/DEBIAN/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Package: mylib
Version: 1.0
Architecture: amd64
Maintainer: Kevin Wang
Installed-Size: 128
Recommends:
Suggests:
Section: devel
Priority: optional
Multi-Arch: foreign
Description: just for test
1 change: 1 addition & 0 deletions debian/mylib/DEBIAN/postinst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#包含了软件在进行正常目录文件拷贝到系统后,所需要执行的配置工作
1 change: 1 addition & 0 deletions debian/mylib/DEBIAN/postrm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#软件卸载后需要执行的脚本
1 change: 1 addition & 0 deletions debian/mylib/DEBIAN/prerm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#软件卸载前需要执行的脚本
16 changes: 16 additions & 0 deletions debian/mylib/usr/include/mylib.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#ifndef MYLIB_H
#define MYLIB_H

#include <string>

using std::string;

class MyLib
{

public:
string sayHello(const char* name);
MyLib();
};

#endif // MYLIB_H
40 changes: 40 additions & 0 deletions debian/pkg_upload.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env python3

import json
import os


import subprocess
def excuteCommand(com):
ex = subprocess.Popen(com, stdout=subprocess.PIPE, shell=True)
out, err = ex.communicate()
status = ex.wait()
#print("cmd in:", com)
#print("cmd out: ", out.decode())
return out.decode()

com = 'ls *.deb > pkg.txt'
print("com = ", com)
tmp = excuteCommand(com)


f = open('pkg.txt')
pkg = f.read()
f.close()
print("pkg = ", pkg)
pkg = pkg.split('\n')
print("len = ", len(pkg))
com = ''
i=0

for i in range(len(pkg)):
if (pkg[i] != ""):
com = "curl -v -u admin:admin -X POST http://192.168.0.27:8081/service/rest/v1/components?repository=apt-hosted -F apt.asset=@"+(pkg[i])
print("com = ", com)
tmp = excuteCommand(com)
i= i+1


com = 'rm pkg.txt'
print("com = ", com)
tmp = excuteCommand(com)
1 change: 1 addition & 0 deletions git-cmd.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
git clone [email protected]:bplatform/helloworld-gui.git /app/SRC
Binary file added lib.tar
Binary file not shown.
11 changes: 11 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include "mainwindow.h"
#include <QApplication>

int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();

return a.exec();
}
57 changes: 57 additions & 0 deletions mainwindow.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#include "mainwindow.h"
#include "ui_mainwindow.h"

#include <mylib.h>
#include <mylibext.h>

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

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

void test(){

}

void MainWindow::on_pushButton_clicked()
{
ui->textEdit->append( "Hello World! ");
ui->textEdit->append( tr("测试中文"));

MyLib mylib;
MyLibExt mylibExt;
ui->textEdit->append( "mylib.sayHello ");
ui->textEdit->append(QString::fromStdString(mylib.sayHello("wiseking")));
ui->textEdit->append( tr(""));
ui->textEdit->append( "mylibExt.sayHello ");
ui->textEdit->append(QString::fromStdString(mylibExt.sayHello("wiseking")));
ui->textEdit->append( tr(""));
ui->textEdit->append( "mylibExt.sayHelloExt ");
ui->textEdit->append(QString::fromStdString(mylibExt.sayHelloExt("wiseking")));
ui->textEdit->append( tr(""));
ui->textEdit->repaint();
}

void MainWindow::on_pbLib_clicked()
{
MyLib mylib;
MyLibExt mylibExt;
ui->textEdit->append( "mylib.sayHello ");
ui->textEdit->append(QString::fromStdString(mylib.sayHello("wiseking")));
ui->textEdit->append( tr(""));
ui->textEdit->append( "mylibExt.sayHello ");
ui->textEdit->append(QString::fromStdString(mylibExt.sayHello("wiseking")));
ui->textEdit->append( tr(""));
ui->textEdit->append( "mylibExt.sayHelloExt ");
ui->textEdit->append(QString::fromStdString(mylibExt.sayHelloExt("wiseking")));
ui->textEdit->append( tr(""));
ui->textEdit->repaint();

}
29 changes: 29 additions & 0 deletions mainwindow.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>

extern void test();

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
Q_OBJECT

public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
void test();

private slots:
void on_pushButton_clicked();
void on_pbLib_clicked();

private:
Ui::MainWindow *ui;
};

#endif // MAINWINDOW_H
Loading

0 comments on commit f43afea

Please sign in to comment.