首先,我已经看到了一些解决方案,但我并不了解它们。我是QT的新手,甚至谷歌都没有帮助我。英语不是我的第一语言
这是在QT Creator 5.6中调试后的错误消息
C2143:语法错误:缺少';'之前' *'
C4430:缺少类型说明符 - 假设为int。注意:C ++没有 支持default-int
C2238:';'
之前的意外令牌
这是文件
secdialog.h
import java.util.InputMismatchException;
import java.util.Scanner;
public class WeightOnADifferentPlanet {
public static void main ( String[] args ){
Scanner scan = new Scanner ( System.in );
System.out.println("Where do you want to travel:?");
try{
String planetName = scan.nextLine();
}
catch(/*need help here*/){
System.out.println("Please check your spelling");
}
System.out.println("Please enter your weight:");
try{
int weight = scan.nextInt();
}
catch(InputMismatchException e)
{
System.out.println("That is not an integer");
}
double earthCalculation = weight * 1.0;
double jupiterCalculation = weight * (21.0 / 8.0); //check
double marsCalculation = weight * (3.0 / 8.0);
double mercuryCalculation = weight * (3.0 / 10.0);
double neptuneCalculation = weight * (11.0 / 10.0); //check
double plutoCalculation = weight * (7.0 / 10.0);
double saturnCalculation = weight * (6.0 / 5.0); //check
double uranusCalculation = weight * (9.0 / 10.0);
double venusCalculation = weight * (7.0 / 8.0);
if (planetName.equalsIgnoreCase("Earth"))
{
System.out.println("Your weight on "+planetName+" is: "+earthCalculation+" pounds.");
}
else if (planetName.equalsIgnoreCase("Jupiter"))
{
System.out.println("Your weight on "+planetName+" is: "+jupiterCalculation+" pounds.");
}
else if (planetName.equalsIgnoreCase("Mars"))
{
System.out.println("Your weight on "+planetName+" is: "+marsCalculation+" pounds.");
}
else if (planetName.equalsIgnoreCase("Mercury"))
{
System.out.println("Your weight on "+planetName+" is: "+mercuryCalculation+" pounds.");
}
else if (planetName.equalsIgnoreCase("Neptune"))
{
System.out.println("Your weight on "+planetName+" is: "+neptuneCalculation+" pounds.");
}
else if (planetName.equalsIgnoreCase("Pluto"))
{
System.out.println("Your weight on "+planetName+" is: "+plutoCalculation+" pounds.");
}
else if (planetName.equalsIgnoreCase("Saturn"))
{
System.out.println("Your weight on "+planetName+" is: "+saturnCalculation+" pounds.");
}
else if (planetName.equalsIgnoreCase("Uranus"))
{
System.out.println("Your weight on "+planetName+" is: "+uranusCalculation+" pounds.");
}
else if (planetName.equalsIgnoreCase("Venus"))
{
System.out.println("Your weight on "+planetName+" is: "+venusCalculation+" pounds.");
}
}
}
}
很抱歉,如果问题中已经存在问题,但我不了解其他解决方案。
我试图为节目制作一个小节目,它只需要显示一些形式,就是这样。有一些按钮,每个按钮打开另一个表单并隐藏之前的那个。
我的问题是,我总是遇到编程和语言方面的问题,通常我不太了解解决方案,我更多的是"有人告诉我如何然后我使用它并且理解它" - 我通过"复制粘贴"
学习谁能告诉我我做错了什么? 如果您需要有关该项目的更多信息,请询问。
提前谢谢。
这里是请求的tridialog.h
#ifndef SECDIALOG_H
#define SECDIALOG_H
#include <QDialog>
#include "tridialog.h"
#include "quadialog.h"
namespace Ui {
class SecDialog;
}
class SecDialog : public QDialog
{
Q_OBJECT
public:
explicit SecDialog(QWidget *parent = 0);
~SecDialog();
private slots:
void on_pushButton_5_clicked();
void on_status_clicked();
void on_pushButton_2_clicked();
void on_zuteilung_clicked();
private:
Ui::SecDialog *ui;
TriDialog *triDialog; //this is the line with the problem
QuaDialog *quaDialog; // funny thing, he didn't complain about this line
};
#endif // SECDIALOG_H
以下是qt kraftwerk.zip
的整个项目答案 0 :(得分:3)
您的问题出在tridialog.h
:
#include "secdialog.h"
当你包含secdialog.h
时,你会引入你的SecDialog
类声明,它在声明TriDialog
类之前有TriDialog
指针(在有问题的行上)!
由于您实际上不需要secdialog.h
中tridialog.h
的任何内容,只需删除
#include "secdialog.h"
它应该有用。
答案 1 :(得分:1)
看起来你有一个范围错误,除非我误解了你的意图。这段代码:
import tornado
import logging
from tornado.web import RequestHandler
import time
class AnalyticsBWSpecificHour(RequestHandler):
def get(self):
return self.write({'message':'no get method'})
class Application(tornado.web.Application):
def __init__(self,**kwargs):
api_handlers = [
(r"/", AnalyticsBWSpecificHour),
]
logging.debug(api_handlers)
super(Application, self).__init__(api_handlers, **kwargs)
在名称空间from api import Application
from tornado.testing import AsyncHTTPTestCase
import tornado
import logging
logging.basicConfig(level=logging.DEBUG)
import unittest
class ApiTestCase(AsyncHTTPTestCase):
def get_app(self):
self.app = Application(debug=True)
return self.app
def test_status(self):
print(self.get_url('/'))
response = self.fetch(self.get_url('/'),method='GET')
self.assertEqual(response.code,200)
if __name__ == '__main__':
unittest.main()
中声明一个名为namespace Ui {
class TriDialog;
}
class TriDialog : public QDialog
{};
的类,然后在名称空间TriDialog
之外声明一个名为Ui
的类。您现在有两个类TriDialog
和Ui
。您需要将整个定义放在命名空间范围内。
修改强> 看起来skearney发现了你所问的错误,但这仍然是一个问题。