我不知道如何表达这个问题,但在 Windows 上使用 Python 时出现错误。事实是,即使去掉了python本身,也能得出这样的结论。最新版本。
Дмитрий Гуща's questions
我真的无法理解为什么在执行这样的循环时,调试器没有进入 std::cin的实现(cin 是 while 中的那个)。请解释为什么会这样。
int choiceMenu = 0;
std::cin >> choiceMenu;
while (choiceMenu < 1 || choiceMenu > 5 || std::cin.fail()) {
std::cout << "Invalid choice, try again: ";
std::cin >> choiceMenu;
}
不执行最后一个条目cin
,但执行第一个cin
条目并且程序请求数据。循环结束后,自然会重新开始,但这一次甚至没有进入第一个cin
。在调试器上,它显示最后一行被简单地忽略了。
int stopCreatingStudents = 0;
while (stopCreatingStudents != 1) {
Student* student = new Student();
std::string name;
cout << "Input a name of a student: ";
cin >> name;
student->setName(name);
newGroup.addStudent(student);
cout << "Stop to create students?(0 - No, 1 - Yes): ";
cin >> stopCreatingStudents;
}
一般来说,我需要对字符的存在进行字符串检查,以便字符串可以包含字母和数字,但禁止存在其他字符
cout << "Name the Group(use letters and digits): ";
cin >> title;
while(/*здесь хочу вставить условие*/) {
cout << "You can't use symbols except letters and digits, try again: ";
cin >> title;
}
我认为这是一个愚蠢的问题,但我还是会问。如何正确重载 QAbstractButton::clicked(). 但我不确定我是否真的需要它。
connect(addBtn, SIGNAL(clicked()), this, SLOT(MainWindow::addTimerBtn(timeEdit,textEdit)));
我决定使用这行代码将插槽绑定到信号。但是我明白信号也应该是我写的吧?最初,我不想通过连接来做到这一点,而只是通过 if 条件。请告诉我如何
一般来说,我不明白如何正确创建第二个窗口。有一个函数 addTimer() 作为主窗口类 MainWindow 的方法。
class MainWindow : public QMainWindow
{
public:
MainWindow();
protected:
void timerEvent(QTimerEvent *e);
QMap<QTimer*,QTextEdit*> getTimers();
private:
QToolBar *toolbar;
void setToolBar();
QLabel *timelbl;
QLabel *mainTimerLbl;
QTextEdit *mainTimerDescriptionLbl;
QListWidget *listW;
QMap<QTimer*,QTextEdit*> timers_descriptions;
QWindow *addWindow;
void addTimer();
};
函数本身
void MainWindow::addTimer()
{
addWindow = new QWindow();
addWindow->resize(200,120);
addWindow->setTitle("New Timer");
QLabel *timeLbl = new QLabel("Time",this);
timeLbl->setGeometry(20,60,50,20);
QTimeEdit *timeEdit = new QTimeEdit(this);
timeEdit->setGeometry(90,65,100,25);
addWindow->show();
}
一般情况下,窗口已创建,但不会出现 QLabel 和 QTimeEdit。告诉我正确的方法
任务说明如下:
使用表示为稀疏列表的向量和矩阵来实现工作。实现加法、标量乘法、矩阵乘向量、矩阵乘法、矩阵转置等操作。
什么是稀疏列表,你需要知道什么来实现这个任务?
我将用 C++ 编写
main.cpp 文件
#include "menu.h"
using namespace sf;
int main() {
bool isGame = true;
bool isg = true;
while (game.isOpen()) {
while (isg) {
while (isGame) {
...
if (y > 500) {
isGame = false;
Menu(game, score);
break;
}
...
}
isGame = true;
}
}
return 0;
}
菜单.h 文件
#pragma once
#ifndef _MENU_H
#define _MENU_H
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>
#include <iostream>
#include <Time.h>
using namespace sf;
void Menu(RenderWindow& game,int score) {
bool isMenu = true;
while (isMenu) {
if (Mouse::isButtonPressed(Mouse::Left)) {
if (menuNum == 1) {
isMenu = false;
}
}
}
}
#endif _MENU_H
在我看来,当对象低于 500 个单位时,就会调用 void Menu() 函数。然后如果我想再玩一次,在这种情况下,这里是条件`
if (Mouse::isButtonPressed(Mouse::Left)) {
if (menuNum == 1) {
isMenu = false;
}
` 然后我就退出 void Menu() 函数循环,回到原来的循环。但是,与此同时,什么也没有发生,但按计划 - 然后我退出主文件中的“最深”循环,将变量设置为 true 并返回“最深”循环。对不起,如果我用这个文字折磨你,在我看来错误在于表面,但我想不出来
如何将第三方文件夹推送到 github 存储库?在我看来这不是一个困难的问题,我只是对一系列命令感兴趣,我通过 Git Bash 推送