我正试图绕过AOP,一些Qt代码真的会有所帮助.
从维基百科这里有一些示例代码(很容易让Qt/C++程序员阅读):
void transfer(Account fromAcc, Account toAcc, int amount, User user, Logger logger)
throws Exception {
logger.info("transferring money...");
if (! checkUserPermission(user)){
logger.info("User has no permission.");
throw new UnauthorizedUserException();
}
if (fromAcc.getBalance() < amount) {
logger.info("Insufficient Funds, sorry :( ");
throw new InsufficientFundsException();
}
fromAcc.withdraw(amount);
toAcc.deposit(amount);
//get database connection
//save transactions
logger.info("Successful transaction. :) ");
}
Run Code Online (Sandbox Code Playgroud)
然后"aspectized":
void transfer(Account fromAcc, Account toAcc, int amount) throws Exception {
if (fromAcc.getBalance() < amount) {
throw new InsufficientFundsException();
}
fromAcc.withdraw(amount);
toAcc.deposit(amount);
} …Run Code Online (Sandbox Code Playgroud) 有一个包含以下内容的SomeLib.pro文件:
CONFIG += debug
TEMPLATE = lib
TARGET = SomeLib
..
Run Code Online (Sandbox Code Playgroud)
然后在依赖SomeApp.pro中:
..
debug:LIBS += -lSomeLib_debug
..
Run Code Online (Sandbox Code Playgroud)
如果我在qmake中触及SomeLib,如何强制构建SomeApp?
如果我们在tr()中包装字符串,我们可以使用语言学家来翻译qt应用程序.以下示例是动态加载语言的一种方法:
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QTranslator translator;
translator.load("hellotr_la");
app.installTranslator(&translator);
QPushButton hello(QPushButton::tr("Hello world!"));
hello.resize(100, 30);
hello.show();
return app.exec();
}
Run Code Online (Sandbox Code Playgroud)
我想要做的是根据用户偏好翻译成不同的语言.原因是我有一台服务器需要处理具有不同语言的客户端请求.通过每个请求的事件使整个服务器/进程更改语言感觉不对.因此,我对动态翻译的反应不感兴趣QEvent::LanguageChange.
因此,我感兴趣的一件事是QCoreApplication :: installTranslator()的以下文档
可以安装多个翻译文件.按照安装它们的相反顺序搜索翻译,因此首先搜索最近安装的翻译文件,最后搜索安装的第一个翻译文件.只要找到包含匹配字符串的翻译,搜索就会停止.
因此,似乎可以加载多种语言,但我担心的是,如果我有多种语言,我无法指定哪一种语言是首选语言.如果我必须在代码中表达我想要的是这样的:
QString MyApplicationServer::OnHandleRequest(MyRequest &r)
{
//Get the language for this specific request
//For example language can be “hellotr_la” or “hellotr_fr”
// Or another way: "lat", "fra", "enu", "esn" ...
QString language = getLanguageForRequest(r);
//How do I dynamically use language or translate to language?
// This would …Run Code Online (Sandbox Code Playgroud) 我需要实现一个简单的消息总线:
我正在考虑使用QSignalMapper来标记"命名事件",然后从插槽重新发出或将发布者信号连接到用户的信号......
有什么建议吗?或者我应该采用相对简单的设计模式?
PS:在Windows上使用D-Bus的AFAICS,您需要安装"第三方"软件才能使用Qt.
我听说过域驱动的设计模式,但不知道它究竟是什么.是设计模式吗?如果是这样,那么它与mvc或mvp的区别.请讨论一下.如何用c#实现域驱动设计模式.
我如何设置我的文本样式<Typography />?是否可以做这样的事情:
const someText = 'Hello <b>World</b>';
...
<Typography>
{someText}
</Typography>
...
Run Code Online (Sandbox Code Playgroud)
或者我需要拆分我的文本吗?对于嵌套的版式,我似乎遇到了一些布局问题。
我想获得修改记录的最后日期.这是一个简单的SELECT示例:
SELECT
t01.name,
t01.last_upd date1,
t02.last_upd date2,
t03.last_upd date3,
'maxof123' maxdate
FROM
s_org_ext t01,
s_org_ext_x t02,
s_addr_org t03
WHERE
t02.par_row_id(+)= t01.row_id and
t03.row_id(+)= t01.pr_addr_id and
t01.int_org_flg = 'n';
Run Code Online (Sandbox Code Playgroud)
如何获取maxdate列以显示三个日期的最大值?
注意:没有UNION或子/嵌套SELECT语句;)
qt ×4
c++ ×3
aop ×1
c# ×1
dbus ×1
dependencies ×1
material-ui ×1
oracle ×1
qmake ×1
qt4 ×1
reactjs ×1
sql ×1
translation ×1