Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/160.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ QT创建者C++;不为一个项目生成ui_uh.h文件_C++_Qt - Fatal编程技术网

C++ QT创建者C++;不为一个项目生成ui_uh.h文件

C++ QT创建者C++;不为一个项目生成ui_uh.h文件,c++,qt,C++,Qt,我一直在开发我的UI,所有的东西都编译得很好,但我也编写了大部分代码,然后部分生成了头文件。但是这个头文件不会编译-没有错误。它根本不在构建目录中 墨水 \ifndef墨水 #定义墨迹 #包括 名称空间用户界面{ 类墨水; } 类别墨水:公共设备 { 公众: 显式墨水(QWidget*parent=0); ~Ink(); 私人: Ui::Ink*Ui; }; #endif//INK\u H ink.cpp #include "ink.h" #include <QtCore> #i

我一直在开发我的UI,所有的东西都编译得很好,但我也编写了大部分代码,然后部分生成了头文件。但是这个头文件不会编译-没有错误。它根本不在构建目录中

墨水

\ifndef墨水
#定义墨迹
#包括
名称空间用户界面{
类墨水;
}
类别墨水:公共设备
{
公众:
显式墨水(QWidget*parent=0);
~Ink();
私人:
Ui::Ink*Ui;
};
#endif//INK\u H
ink.cpp

#include "ink.h"

#include <QtCore>
#include <QtGui>
#include <QWidget>
#include <QPainter>
#include <QPaintEvent>

void ink()
{


    QFile *brushInput; //takes raw 8 bit grayscale image, 8 bit values only
    char *brushProto;
    uchar *brushData;


    brushInput = new QFile("x:\\Development\\InkPuppet\\brush.raw"); //open the raw file
    brushInput->open(QIODevice::ReadOnly);
    QDataStream in;
    in.setDevice(brushInput);
    int size = brushInput->size(); //set size to length of raw file

    brushProto = new char[size];
    in.readRawData(brushProto, size); //read file into prototype
    brushData = new uchar[size];

    for(int i = 0; i < size; ++i)
    {
        brushData[i] = (uchar)brushProto[i]; //copy char to uchar array
    }

    QImage test(brushData, 128, 128, QImage::Format_Indexed8);
    QImage test2(128, 128, QImage::Format_ARGB32);

    QVector<QRgb> vectorColors(256); //create color table
    for(int c = 0; c < 256; c++)
    {
        vectorColors[c] = qRgb(c, c, c);
    }

    test.setColorTable(vectorColors);

    for(int iX = 0; iX < 100; ++iX)
    {
        for(int iY = 0; iY < 100; ++iY)
        {
            test2.setPixel(iX, iY, qRgba(255 - (qrand() % 100), 0 + (qrand() % 100), 0 + (qrand() % 100), qAbs((int)test.pixel(iX, iY)-255)));
        }
    }

    //final conversion for stencil and color brush
    QPixmap testPixmap = QPixmap::fromImage(test2);
    QPixmap testPixmap2 = QPixmap::fromImage(test);

    QPainter painter(this);

    painter.drawPixmap(150, 50, 100, 100, testPixmap);
    painter.drawPixmap(50, 50, 100, 100, testPixmap2);

    delete[] brushProto;
    delete[] brushData;
    delete brushInput;
}
#包括“ink.h”
#包括
#包括
#包括
#包括
#包括
无效墨水()
{
QFile*brushInput;//获取原始8位灰度图像,仅8位值
char*brushProto;
uchar*数据;
brushInput=new QFile(“x:\\Development\\InkPuppet\\brush.raw”);//打开原始文件
brushInput->open(QIODevice::ReadOnly);
qdatastreamin;
in.setDevice(输入);
int size=brushInput->size();//将大小设置为原始文件的长度
brushProto=新字符[大小];
in.readRawData(brushProto,size);//将文件读入原型
brushData=新的uchar[尺寸];
对于(int i=0;i
main.cpp

#include "inkpuppet.h"
#include "ink.h"
#include <QApplication>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    InkPuppet w;
    w.show();

    return a.exec();
}
#包括“inkpuppet.h”
#包括“ink.h”
#包括
int main(int argc,char*argv[])
{
质量保证申请a(argc、argv);
InkW;
w、 show();
返回a.exec();
}

当您在QT creator中创建新表单时,您必须选择QT Designer表单类以生成相应的.cpp和.h文件,否则它将只生成.ui。

您通常不编译头文件,只需将它们包含在您编译的文件中。您的意思是什么?qt creator没有从file.ui生成ui_file.h?这是你的问题吗?那么什么是墨水?这是所需的文件,但qt designer没有更新吗?我的意思是,当我在调试文件夹中运行程序时,ink.h的文件没有被编译。这里有“moc_aboutdialog.cpp”和obj(来自aboutdialog文件),“moc_inkpuppet.cpp”&obj但在构建中没有moc.ink.cpp或obj或任何与其相关的文件。这是生成.h文件的方式:uic CointegrationGUI.ui-o ui_CointegrationGUI.h。我对QtCreator有很多问题,并且几乎总是以这种方式生成文件,因为Creator不会自己更新它们,但我使用IDE工具的奇怪配置,这可能在3年前有所帮助。@Vii我也遇到过同样的问题,我用这种方式解决了。这就是我决定发帖的原因。
#include "inkpuppet.h"
#include "ink.h"
#include <QApplication>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    InkPuppet w;
    w.show();

    return a.exec();
}