class myException : public QException { myException(const char msg[]) {f_msg = QString::fromUtf8(msg);}public: QString message(); void raise() const override { throw *this; } Exception *clone() const override { return new MyException(*this); }private: QString f_msg;};
throw myException("some text");
try { ........... } catch (myException e) { QMessageBox::critical(&w, "Ошибка", e.message()); return 1; }}
{ return new myException(this.message().toUTF8()); }
const QString S_ERR_CONFIGISMISSING = "Не задана конфигурация";
public: Exception(const char msg[]) { f_message = String::fromUtf8(msg); } Exception(const char *cformat, ...) { .... }
#ifndef RC_STRINGS_H#define RC_STRINGS_H#include <QString>static const QString testString = "Test string";
ххххх\rc_strings.h:5:1: non-POD static (QString) [clazy-non-pod-global-static]
C++ (Qt)const auto s = QStringLiteral("my string");
C++ (Qt)const auto errorFormat = QStringLiteral("error in %1, message %2"); const auto formattedError = errorFormat.arg(filePath).arg(fileError);
const char S_ERRORSTR[] = "error string";const char S_FMTERR[] = "%s %.3f %.3f";...throw MyException(S_ERRORSTR);...throw MyException(S_FMTERR, x, y);
class Exception : public QException {protected: String f_message;public: Exception(const char fmt[], const void *[]) { .............. }
C++ (Qt)Exception(QString s);