小编Dee*_*dit的帖子

我如何声明一个函数,该函数将一个尚未识别的类型的变量作为参数

问题是标题所示.O得到错误:期望的类型标识符,(我认为)来自在类型声明之前读取的函数声明.

type
  TForm1 = class(TForm)
    //other declarations
    function ItemThere(x: TItem): boolean; // here it says TItem is unknown
  end;

type
  TItem = class
    Name : String;
    Description : String;
    constructor Create;
  end;
Run Code Online (Sandbox Code Playgroud)

另外,我想让你知道我是一个相当缺乏经验的程序员.我怎样才能解决这个问题?我应该将TItem的声明移到TForm1之上吗?谢谢您的帮助.

delphi types declaration lazarus

2
推荐指数
1
解决办法
122
查看次数

如何修复QObject :: connect:没有这样的插槽..将发送方连接到同一个类中的插槽时

我正在编写一个程序,创建一个QLineEdit,该QLineEdit仅接受数字,并且在拒绝非数字的输入时应将背景变为任意颜色。如果输入有效,它将再次使背景变白。现在,我需要将QLineEdit的inputRejected和textEdited事件分别连接到randomcolor()和white(),但是连接使我很麻烦,而且我不知道如何解决它。

这是我第一次使用连接,并且我在许多论坛上摸索着尝试在这里找到的不同语法。

#include <QtWidgets>

class OnlyNumbers : QLineEdit {
   public:
        static int spawn(int argc, char *argv[]){
            QApplication app(argc, argv);
            OnlyNumbers P;
            return app.exec();
        }
        OnlyNumbers() : QLineEdit() {
            this->setValidator(new QIntValidator());
            QObject::connect(this, SIGNAL(inputRejected()), this, SLOT(randomcolor()));
            QObject::connect(this, SIGNAL(&QLineEdit::textEdited(const QString)), this, SLOT(&OnlyNumbers::white()));
            QRegExp rx("[0-9]*");            QValidator *validator = new QRegExpValidator(rx, this);
            this->setValidator(validator);
            this->show();

        }
    public slots:
        void randomcolor(){
            this->setStyleSheet("QLineEdit { background: rgb(std::rand()%256, rand()%256, rand()%256); selection-background-color: rgb(rand()%256, rand()%256, rand()%256); }");
        }
        void white(){
            this->setStyleSheet("QLineEdit { background: rgb(255, 255, 255); selection-background-color: rgb(233, 99, 0); }");
        } …
Run Code Online (Sandbox Code Playgroud)

c++ qt qt5

-2
推荐指数
1
解决办法
65
查看次数

标签 统计

c++ ×1

declaration ×1

delphi ×1

lazarus ×1

qt ×1

qt5 ×1

types ×1