Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions 2_Sing08.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#-------------------------------------------------
#
# Project created by QtCreator 2020-02-08T18:10:09
#
#-------------------------------------------------

QT += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = 2_Sing08
TEMPLATE = app

# The following define makes your compiler emit warnings if you use
# any feature of Qt which has been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS

# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0

CONFIG += c++11

SOURCES += \
main.cpp \
mainwidget.cpp \
subwidget.cpp

HEADERS += \
mainwidget.h \
subwidget.h
CONFIG += C++11
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
328 changes: 328 additions & 0 deletions 2_Sing08.pro.user

Large diffs are not rendered by default.

20 changes: 1 addition & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1 @@
# practice
平时练习的代码
import numpy as np
import matplotlib.pyplot as plt
import math
def draw_heart():
t=np.linspace(0,math.pi,1000)
x=np.sin(t)
y=np.cos(t)+np.power(x,2.0/3)
plt.plot(x,y,color='red',linewidth=2,label='h')
plt.plot(-x,y,color='red',linewidth=2,label='h')
plt.fill_between(x, y, where=(2.3<x) & (x<4.3) | (x>10))
plt.xlabel('t')
plt.ylabel('h')
plt.ylim(-2,2)
plt.xlim(-2,2)
plt.legend()
plt.show()
draw_heart()
为每日提高自己的练习代码
11 changes: 11 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include "mainwidget.h"
#include <QApplication>

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

return a.exec();
}
53 changes: 53 additions & 0 deletions mainwidget.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#include "mainwidget.h"
#include <QPushButton>
MainWidget::MainWidget(QWidget *parent)
: QWidget(parent)
{

b1.setParent(this);
b1.setText("close");
b1.move(100,100);

b2 = new QPushButton(this);
b2->setText("lalala");

connect(&b1, &QPushButton::pressed,this,&MainWidget::close);

connect(b2,&QPushButton::released,this,&MainWidget::mySlot);
connect(b2,&QPushButton::released,&b1,&QPushButton::hide);


setWindowTitle("老大");
b3.setParent(this);
b3.setText("切换到子窗口");
b3.move(50,50);

//w.show();

//处理子窗口信号
connect()

QPushButton *b5 = new QPushButton(this);
b5->setText("Lambbda");
int a=1,b=2;
connect(b5,&QPushButton::released(),
//= 把外部所有局部变量,类中所有成员一值传递 传进变量只读 修改加mutable
//& 外部所有局部变量
//this 类中所有
// ()中可以传参
[=]() mutable
{
b5->setText("fa");
qDebug() << "111";
})

}

void MainWidget::mySlot()
{
b2->setText("123");
}
MainWidget::~MainWidget()
{

}
22 changes: 22 additions & 0 deletions mainwidget.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#ifndef MAINWIDGET_H
#define MAINWIDGET_H

#include <QWidget>
#include <QPushButton>
#include "subwidget.h"
class MainWidget : public QWidget
{
Q_OBJECT

public:
MainWidget(QWidget *parent = 0);
~MainWidget();
void mySlot();
private:
QPushButton b1;
QPushButton *b2;
QPushButton b3;
subWidget w;
};

#endif // MAINWIDGET_H
15 changes: 15 additions & 0 deletions subwidget.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include "subwidget.h"

subWidge::subWidge(QWidget *parent) : QWidget(parent)
{
this->setWindowTitle("xiaodi");
b4,setParent(this);
b4.setText("切换到主窗口");

connect(&b4,&QPushButton::clicked,this,&subWidge::sendSlot);
}

void subWidge::sendSlot()
{
emit mySignal();
}
23 changes: 23 additions & 0 deletions subwidget.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#ifndef SUBWIDGE_H
#define SUBWIDGE_H

#include <QWidget>
#include <QPushButton>
class subWidge : public QWidget
{
Q_OBJECT
public:
explicit subWidge(QWidget *parent = nullptr);
void sendSlot();

signals:
/*信号就是函数的声明,只需声明,无需定义*/
void mySignal();

public slots:

private:
QPushButton b4;
};

#endif // SUBWIDGE_H