Qt c ++字符串中的.arg错误(Qt c++ .arg error in string)
我收到了错误:请求成员'arg'在'(“学生编号:%1模块代码:%2标记:%3”)',这是非类型'const char [43]
无法弄清楚为什么我收到这个错误
这是产生错误的函数:
void StudentForm::displayForm(){ QMessageBox box; box.setIcon(QMessageBox::Information); stuNum = stuEdt->text().toInt(); mark = markSbx->text().toInt(); modCode = codeEdt->text(); QString t = ("Student number:%1 Module Code: %2 Mark: %3").arg(stuNum).arg(modCode).arg(mark); box.setText(t); box.exec(); }
如果我需要更多的代码等,请告诉我。谢谢
I have been getting the error: request for member 'arg' in '("Student number:%1 Module Code: %2 Mark: %3")', which is of non-class type 'const char [43]
can't figure out why I'm getting this error
here is the function that produces the error:
void StudentForm::displayForm(){ QMessageBox box; box.setIcon(QMessageBox::Information); stuNum = stuEdt->text().toInt(); mark = markSbx->text().toInt(); modCode = codeEdt->text(); QString t = ("Student number:%1 Module Code: %2 Mark: %3").arg(stuNum).arg(modCode).arg(mark); box.setText(t); box.exec(); }
let me know if I need to put more of the code up etc. Thanks
原文:https://stackoverflow.com/questions/18472791
最满意答案
这是标准行为。 SQLAlchemy不会根据其他更改反映外键更改或关系更改,直到提交为止。 如果要在设置其他属性时设置属性,则可以使用“ 属性集”事件。
通常鼓励您使用关系并忽略外键,因为SQLAlchemy在设置关系时会在后台执行很多很好的“魔术”。 如果您希望外键执行相同的魔术,请参阅FK更改配方的过期关系 。
这只是我现在的意见,但这不是一个“红旗”。 您应该构建程序以避免在新实例或更新实例与持久实例之间进行比较。
That is the standard behavior. SQLAlchemy will not reflect foreign key changes or relationship changes based on the other changing until commit. If you would like to set the property when the other is set, you can use the Attribute Set event.
You are usually encouraged to use the relationship and ignore the foreign key, as SQLAlchemy will perform a lot of nice "magic" in the background when setting relationships. If you would like foreign keys to perform this same magic, see the Expire Relationship on FK Change recipe.
This is just my opinion now, but this is not a "red flag". You should instead structure your program to avoid comparison between new or updated instances and persistent instances.
相关问答
更多-
SQLAlchemy:ValueError(SQLAlchemy: ValueError)[2022-09-30]
问题解决了! 这是门票: http : //sqlalchemy.org/trac/ticket/2674 Problem solved! Here is the ticket: http://sqlalchemy.org/trac/ticket/2674 -
所以我发现了第二个问题的答案......就这么做 @property def Teacher(self): return self.Class.Teacher 这对于python类是通用的(我认为只有新风格)。 现在 s1.Class.Teacher 返回Teacher对象。 编辑:由于没有其他人回答我的问题,而且我的所有代码都按照我的想法运作,我会说我用正确的方式编写代码(参考问题1)。 So I discovered the answer to my second question... J ...
-
好吧,伙计们,我自己想通了。 我有几个我搞乱的文件,其中有表定义(从sqlautocode输出)。 一个被称为'database.py'另一个'model.py'和最后一个'ORM.py'。 我有一个导入'model.py'的test.py文件。 Model.py是我编写表定义的文件。但是 - test.py页面还从Flask( from app import app, db ) from app import app, db ,并在Flask应用程序的__init__()函数中from app impor ...
-
在SQLAlchemy中替换整个集合时验证/强制值(Validate/coerce values when replacing an entire collection in SQLAlchemy)[2023-04-27]
事实上,这是意想不到的行为,更多的是设计上的缺陷。 为了更好地解决1.2 问题,我们打开了一个问题,但同时解决方法是使用@collection.converter装饰器使用自定义集合: class MyCollection(list): @collection.converter def convert(self, value): return [RelType(**v) if not isinstance(v, RelType) else v for v in value] ... -
我如何使用int而不是实例查询sqlalchemy关系?(How can I query a sqlalchemy relationship with an int instead of an instance?)[2022-02-13]
找到了一种方法, Bar.foo.prop.local_columns是RelationshipProperty的一个属性,它通常返回一个集合中的一个项目(对于像这样的简单关系)。 集合是无序的,你不能只获得第一个项目,所以list(...)[0] 。 完整代码: def method_4(session, some_foo_id): foo_col = list(Bar.foo.prop.local_columns)[0] session.query(Bar).filter(foo_col ... -
您需要在对象初始化时传递user_receiver_id和user_shipper_id 。 我没有对此进行测试,但您可以尝试将其用作洞察力! class UserShipper(): ... bars = relationship('Bar', back_populates='shipper', lazy='dynamic') class UserReceiver(): ... bars = relationship('Bar', back_populates='rec ...
-
Django - 通过ForeignKey属性将参数传递给模型(Django - Passing arguments to models through ForeignKey attributes)[2022-04-16]
你可能会把它推上去; 尝试将参数应用于FK是不常见的。 您的细节的传统解决方案是使用缩略图(如“sorl”)在交付前立即进行缩略图替换 - 即:在模板中,例如: {% thumbnail myobj.image 500 500 %} 虽然我个人已经在我的类中添加了例程,以便更容易访问这些缩略图。 例如: def thumbnail(self): path = # work out the path to the thumbnail try: #access the p ... -
我真正想从SQLAlchemy获得的是一次性提取所有(或所有相关的)挑战,然后将其与相关尝试相关联。 如果所有的挑战都被拉下来,或者只有后来才有实际的关联,这并不是什么大不了的事情, 你首先想要从relationship()中取出那个“lazy ='subquery'”指令; 修复关系以始终加载所有内容,这就是为什么你会遇到查询爆炸的原因。 特别是在这里,你正在为Challenge->尝试正确加载每个UserAttempt-> Challenge的延迟加载,所以你在这里设计了最糟糕的加载组合:)。 有了这个 ...
-
如果Investor和Round之间存在多对多的关系,您可以按如下方式定义模型: class Investor(db.Model): id = db.Column(db.Integer, primary_key=True) rounds = db.relationship('Round', secondary=investments, backref='investor') class Round(db.Model): id = db.Column(db.Integer, prim ...
-
这是标准行为。 SQLAlchemy不会根据其他更改反映外键更改或关系更改,直到提交为止。 如果要在设置其他属性时设置属性,则可以使用“ 属性集”事件。 通常鼓励您使用关系并忽略外键,因为SQLAlchemy在设置关系时会在后台执行很多很好的“魔术”。 如果您希望外键执行相同的魔术,请参阅FK更改配方的过期关系 。 这只是我现在的意见,但这不是一个“红旗”。 您应该构建程序以避免在新实例或更新实例与持久实例之间进行比较。 That is the standard behavior. SQLAlchemy w ...