使用两个数组时进行statetransition

时间:2018-11-13 17:12:46

标签: c++

我正在使用两个c ++二维数组A1和A2。可以说,A1应该代表初始状态,而A1 = A2(就在第一轮!)。接下来,我要使用A1保存旧状态,并使用A2保存计算机的当前状态。

我的问题是: -如何覆盖A2的值? -完成一回合后,如何用A2的状态覆盖A1的状态。

我以前的尝试:我只是使用了这些值。

gridOptions

问题是,A2中没有应用任何更改。

1 个答案:

答案 0 :(得分:0)

您可以使用memcpy将一个数组复制到另一个数组:

import sys

from PyQt5.QtWidgets import QWidget, QLabel, QLineEdit, QGridLayout, QApplication, QPushButton, QScrollArea, QVBoxLayout, QListWidget, QStackedWidget, QHBoxLayout, QFormLayout, QRadioButton, QCheckBox
from PyQt5.QtCore import *
from PyQt5.QtGui import *

class Pencere (QWidget):
    def __init__(self):
        super().__init__()
        self.init_ui()

    def init_ui(self):
        self.liste = QListWidget()
        self.liste.insertItem(2, "PAGE 1")
        self.stackedwidget = QStackedWidget()
        self.w3 = QWidget()
        self.w3lay()
        self.stackedwidget.addWidget(self.w3)
        hbox = QHBoxLayout()
        hbox.addWidget(self.liste)
        hbox.addWidget(self.stackedwidget)
        self.setLayout(hbox)
        self.liste.currentRowChanged.connect(self.uygula)
        self.setWindowTitle("TITLE")
        self.show()

    def uygula(self,q):
        self.stackedwidget.setCurrentIndex(q)

    def w3lay(self):
        self.checkbox1 = QCheckBox("CHECK 1")
        self.checkbox2 = QCheckBox("CHECK 2 ")
        self.checkbox3 = QCheckBox("CHECK 3")
        self.yazi_alani = QLabel("")
        self.yazi_alani2 = QLabel("")
        self.yazi_alani3 = QLabel("")
        self.deneme3 = QHBoxLayout()
        self.deneme = QHBoxLayout()
        self.butonn = QPushButton("BUTTON")
        self.v_box = QVBoxLayout()
        self.v_box.addWidget(self.checkbox1)
        self.v_box.addWidget(self.checkbox2)
        self.v_box.addWidget(self.checkbox3)
        self.v_box.addWidget(self.butonn)
        self.v_box.addWidget(self.yazi_alani2)
        self.v_box.addWidget(self.yazi_alani)
        self.v_box.addWidget(self.yazi_alani3)
        self.v_box.addLayout(self.deneme3)
        self.v_box.addLayout(self.deneme)
        self.v_box.addStretch()
        self.h_box = QHBoxLayout()
        self.h_box.addStretch()
        self.h_box.addLayout(self.v_box)
        self.h_box.addStretch()
        self.butonn.clicked.connect(lambda: self.click34(self.checkbox1.isChecked(), self.checkbox2.isChecked(), self.checkbox3.isChecked(), self.yazi_alani, self.deneme, self.yazi_alani2, self.yazi_alani3, self.deneme3))
        self.w3.setLayout(self.h_box)


    def click34(self, checkbox1, checkbox2, checkbox3, yazi_alani, deneme, yazi_alani2, yazi_alani3, deneme3):
        if checkbox1 and not checkbox2 and not checkbox3:
            deneme3.addWidget(QLabel("ABC"))
            yazi_alani2.setText("-----------------------")
            yazi_alani.setText("DEF")
            yazi_alani3.setText("-----------------------")
            deneme.addWidget(QLabel("ABC"))
            deneme.addWidget(QLineEdit())


        elif checkbox2 and not checkbox1 and not checkbox3:
            yazi_alani2.setText("----------------------------")
            yazi_alani.setText("ABC")
            yazi_alani3.setText("----------------------------")
            deneme3.addWidget(QLabel("DEF"))
            deneme.addWidget(QLabel("ABC"))
            deneme.addWidget(QLineEdit())

        elif checkbox3 and not checkbox1 and not checkbox2:
            yazi_alani2.setText("----------------------------")
            yazi_alani.setText("ABC")
            yazi_alani3.setText("----------------------------")
            deneme3.addWidget(QLabel("DEF"))
            deneme.addWidget(QLabel("ABC"))
            deneme.addWidget(QLineEdit())

app = QApplication(sys.argv)
pencere = Pencere()
sys.exit(app.exec_())