我有一个包含两个成员的结构,例如:
struct DataSet {
int x;
int y;
};
Run Code Online (Sandbox Code Playgroud)
...,我必须以一种方法访问它们,但一次只能访问一个,例如:
void foo(StructMember dsm) { // ("StructMember" does not exist)
DataSet ds;
ds.x = 4;
ds.y = 6;
std::cout << ds.dsm * ds.dsm << std::endl;
}
Run Code Online (Sandbox Code Playgroud)
foo(x);
foo(y);
Run Code Online (Sandbox Code Playgroud)
我希望有的输出:
16
36
Run Code Online (Sandbox Code Playgroud)
当我必须解决这样的问题时,我该怎么办?是否有可以访问成员的数据类型?
我想在 PyQt 中制作一个简单的 GUI 应用程序。当一个按钮被点击时,它应该带你到下一页。就像您在安装程序时知道的这些安装对话框一样。
我试图在与 MainWindow 完全相同的位置打开一个新窗口,但这感觉不对。
Soo,这是我的代码:
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.title = "MainWindow"
# Here are some height & width variables
self.initUI()
def initUI(self):
self.setWindowTitle(self.title)
self.setGeometry(self.left, self.top, self.width, self.height)
self.UiComponents()
def UiComponents(self):
self.searchButton = QPushButton("", self)
# alot of UiComponents go here
self.searchButton.clicked.connect(self.make_handleButton("searchButton"))
def make_handleButton(self, button):
def handleButton():
if button == "searchButton":
### here it should go to SearchWindow ###
#elif button == "importButton":
# self.importWindow()
return handleButton
class SearchWindow(QMainWindow):
def __init__(self):
super().__init__()
self.title = "Search …Run Code Online (Sandbox Code Playgroud)