Qt文件被报告为病毒,不会启动

时间:2014-06-02 18:26:07

标签: c++ qt4 antivirus

我最近制作了一个Qt文件并编译了它。在编译之后,我的Avast防病毒软件将其阻止为病毒。我花了好几个小时试图找到语法错​​误/无限循环/输入错误。我已经阅读了其他问题并搜索了问题。我得出的结论是,这是出于我的理解。这是我的文件:

top_secret.h

#ifndef TOP_SECRET_H
#define TOP_SECRET_H

#include <QtGui>

class top_secret : public QMainWindow
{
    Q_OBJECT
    public:
        top_secret();

    private slots:
        void password_ckeck();
        void go_to_page_1();
        void go_to_page_2();
        void go_to_page_3();
        void go_to_page_4();
        void quit();
        void lock();
        void about();

    private:
        QStackedWidget *book;

        QWidget *lock_window;
        QWidget *window1;
        QWidget *window2;
        QWidget *window3;
        QWidget *window4;

        QLineEdit *input;

        QAction *quit_action;
        QAction *lock_action;
        QAction *about_action;

        QMenu *fileMenu;
};
#endif

submain.cpp

#include "top_secret.h"

top_secret::top_secret(){
    //main things
    quit_action = new QAction(tr("Quit"), this);
    about_action = new QAction(tr("About"), this);
    lock_action = new QAction(tr("Lock"), this);

    connect(quit_action, SIGNAL(triggered()), this, SLOT(quit()));
    connect(about_action, SIGNAL(triggered()), this, SLOT(about()));
    connect(lock_action, SIGNAL(triggered()), this, SLOT(lock()));

    fileMenu = menuBar() -> addMenu(tr("File"));
    fileMenu -> addAction(lock_action);
    fileMenu -> addAction(about_action);
    fileMenu -> addSeparator();
    fileMenu -> addAction(quit_action);

    book = new QStackedWidget;

    //lock window
    lock_window = new QWidget;

    QLabel *label = new QLabel(tr("Enter password"));
    input = new QLineEdit;
    QPushButton *button = new QPushButton(tr("Go"));

    connect(button, SIGNAL(clicked()), this, SLOT(password_ckeck()));

    QHBoxLayout *lock_layout;
    lock_layout -> addWidget(label);
    lock_layout -> addWidget(input);
    lock_layout -> addWidget(button);
    lock_window -> setLayout(lock_layout);

    //window 1
    window1 = new QWidget;
    QLabel *label1 = new QLabel("Name: Jakub Jagielski<br>Date of birth: 21/01/2014<br>Gender: Male<br>\
    Interested in: Women<br>Hair colour: Brown<br>Eye colour: brown");
    QPushButton *button1 = new QPushButton(tr("Next"));

    connect(button1, SIGNAL(clicked()), this, SLOT(go_to_page_2()));

    QVBoxLayout *layout1;
    layout1 -> addWidget(label1);
    layout1 -> addWidget(button1);
    window1 -> setLayout(layout1);

    //window 2
    window2 = new QWidget;
    QLabel *label2 = new QLabel("Interests: Piano playing, science,<br>programming, computer science,<br>\
Xbox 360 playing, reading facts,<br>Logical puzzles, security programs,<br>bypassing self-made security \
programs,<br>creating complex security programs,<br>creating 2D games in Python tkinter,<br>creating apps \
like this one.");
    QPushButton *button2previous = new QPushButton("back");
    QPushButton *button2next = new QPushButton("next");

    connect(button2previous, SIGNAL(clicked()), this, SLOT(go_to_page_1()));
    connect(button2next, SIGNAL(clicked()), this, SLOT(go_to_page_3()));

    QHBoxLayout *layout2bottom;
    QVBoxLayout *layout2;
    layout2bottom -> addWidget(button2previous);
    layout2bottom -> addWidget(button2next);
    layout2 -> addWidget(label2);
    layout2 -> addLayout(layout2bottom);
    window2 -> setLayout(layout2);

    //window 3
    window3 = new QWidget;
    QLabel *label3 = new QLabel("Programming languages known by this user<br>rated out of 10:<br>\
    Python: 9/10<br>C++: 8/10<br>Java: 5/10<br>HTML/Css/JavaScript: 8/10<br>PHP: 2/10<br>Batch: 5/10<br>");
    QPushButton *button3previous = new QPushButton("back");
    QPushButton *button3next = new QPushButton("next");

    connect(button3previous, SIGNAL(clicked()), this, SLOT(go_to_page_2()));
    connect(button3next, SIGNAL(clicked()), this, SLOT(go_to_page_4()));

    QHBoxLayout *layout3bottom;
    QVBoxLayout *layout3;
    layout3bottom -> addWidget(button3previous);
    layout3bottom -> addWidget(button3next);
    layout3 -> addWidget(label3);
    layout3 -> addLayout(layout3bottom);
    window3 -> setLayout(layout3);

    //window 4
    window4 = new QWidget;
    QLabel *label4 = new QLabel("This app has only been created <br> to try to make an app with<br>\
    C++ and its wonderful library called Qt.<br>This person's account hasn't been<br>really hacked. In \
    fact, the person<br>has made this app himself.");
    QPushButton *button4previous = new QPushButton("back");
    QPushButton *button4end = new QPushButton("quit");

    connect(button4previous, SIGNAL(clicked()), this, SLOT(go_to_page_3()));
    connect(button4end, SIGNAL(clicked()), this, SLOT(quit()));

    QHBoxLayout *layout4bottom;
    QVBoxLayout *layout4;
    layout4bottom -> addWidget(button4previous);
    layout4bottom -> addWidget(button4end);
    layout4 -> addWidget(label4);
    layout4 -> addLayout(layout4bottom);
    window4 -> setLayout(layout4);

    //main
    book -> addWidget(lock_window);
    book -> addWidget(window1);
    book -> addWidget(window2);
    book -> addWidget(window3);
    book -> addWidget(window4);

    setCentralWidget(book);
}

void top_secret::password_ckeck(){
    QString attempt = input -> text();
    if (attempt == "Jakub"){
        top_secret::book -> setCurrentIndex(1);
    }
}

void top_secret::go_to_page_1(){
    top_secret::book -> setCurrentIndex(1);
}

void top_secret::go_to_page_2(){
    top_secret::book -> setCurrentIndex(2);
}

void top_secret::go_to_page_3(){
    top_secret::book -> setCurrentIndex(3);
}

void top_secret::go_to_page_4(){
    top_secret::book -> setCurrentIndex(4);
}

void top_secret::lock(){
    top_secret::book -> setCurrentIndex(0);
}

void top_secret::quit(){
    QMessageBox messagebox;
    messagebox.setText("Do you really wish to quit?");
    messagebox.setWindowTitle("exit?");
    messagebox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
    if (messagebox.exec() == QMessageBox::Yes){
        close();
    }
}

void top_secret::about(){
    QMessageBox messagebox2;
    messagebox2.setText("This app is a test to try out my new C++ abilities. This app \
    would take me half the time it took me if I wrote it in Python.");
    messagebox2.setWindowTitle("About");
    messagebox2.exec();
}

main.cpp

#include "top_secret.h"
#include <QApplication>

int main(int argc, char *argv[]){
    QApplication app(argc, argv);
    top_secret *program = new top_secret;
    program -> show();
    return app.exec();
}

我对代码的数量感到非常抱歉,我不期待一个完美的答案,但如果我能理解我做错了什么,我会非常高兴。此外,当我添加要被我的防病毒软件忽略的文件时,它只是不启动。

请注意,我的其他Qt程序运行正常,所以我确信这是由于我的代码。

1 个答案:

答案 0 :(得分:1)

我和avast有同样的问题。但这不是Qt具体的事情。 Avast阻止了我编程的所有内容。

您只需要进入设置并取消选中“未知来源”之类的框。 Avast不知道您的程序来自何处并阻止它,因为它可能是病毒。至少那是avast对我的程序所做的。取消选中该复选框后一切正常。