QtDesigner不';更新文件
我有以下问题。我使用Qt设计器创建了一个名为inputwindow.ui的文件。但是当我想使用文件inputwindow.cpp中创建的对象(例如QtDesigner不';更新文件,qt,qt5,qt-designer,Qt,Qt5,Qt Designer,我有以下问题。我使用Qt设计器创建了一个名为inputwindow.ui的文件。但是当我想使用文件inputwindow.cpp中创建的对象(例如couleurRadio)时,会说这个名称不存在 相反,我有一些旧名称,如RadioButton_2,而缺少一些对象,如ColorTexture。cpp文件中包含的ui\u inputwindow.h文件似乎没有从inputwindow.ui 这里有两个屏幕来解释: 谢谢你的帮助 代码如下: inputwindow.cpp #include "inp
couleurRadio
)时,会说这个名称不存在
相反,我有一些旧名称,如RadioButton_2
,而缺少一些对象,如ColorTexture
。cpp文件中包含的ui\u inputwindow.h
文件似乎没有从inputwindow.ui
这里有两个屏幕来解释:
谢谢你的帮助
代码如下:
inputwindow.cpp
#include "inputwindow.h"
#include "ui_inputwindow.h"
#include <QButtonGroup>
#include <QObject>
#include "scene.h"
InputWindow::InputWindow(Scene* scene, QWidget *parent) :
QDialog(parent),
ui(new Ui::InputWindow)
{
ui->setupUi(this);
group = new QButtonGroup(this);
group->addButton(ui->radioButton, 0);
group->addButton(ui->radioButton_2, 1);
connect(ui->group, SIGNAL(buttonClicked(int)), scene, SLOT(setColorOrTextureFromGUI(int)));
}
InputWindow::~InputWindow()
{
delete ui;
}
#包括“inputwindow.h”
#包括“ui_inputwindow.h”
#包括
#包括
#包括“scene.h”
InputWindow::InputWindow(场景*场景,QWidget*父对象):
QDialog(父级),
ui(新ui::InputWindow)
{
用户界面->设置用户界面(此);
组=新的QButtonGroup(此);
组->添加按钮(用户界面->单选按钮,0);
组->添加按钮(用户界面->单选按钮2,1);
连接(ui->组,信号(按钮点击(int)),场景,插槽(SetColorOrtextRefromGUI(int));
}
InputWindow::~InputWindow()
{
删除用户界面;
}
inputwindow.ui:
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>InputWindow</class>
<widget class="QDialog" name="InputWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>256</height>
</rect>
</property>
<property name="windowTitle">
<string>Création de l'objet</string>
</property>
<property name="sizeGripEnabled">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QLabel" name="label">
<property name="minimumSize">
<size>
<width>0</width>
<height>17</height>
</size>
</property>
<property name="text">
<string>Dans cet assistant, vous défnirez une liste de points, vous les relierez pour créer des polygones, puis vous appliquerez une texture pour créer votre objet.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="toolTip">
<string><html><head/><body><p>Choix de la texture qui s'appliquera sur l'objet</p></body></html></string>
</property>
<property name="title">
<string>Type de texture</string>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QRadioButton" name="couleurRadio">
<property name="toolTip">
<string><html><head/><body><p>Sur chaque polygone, la texture sera définie par une couleur unique</p></body></html></string>
</property>
<property name="accessibleName">
<string>couleurRadio</string>
</property>
<property name="text">
<string>Monochrome</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<attribute name="buttonGroup">
<string notr="true">colorOrTexture</string>
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="imageRadio">
<property name="toolTip">
<string extracomment="sdsdsdsdsd"><html><head/><body><p>Une image s'appliquera sur l'objet</p></body></html></string>
</property>
<property name="text">
<string>Image</string>
</property>
<attribute name="buttonGroup">
<string notr="true">colorOrTexture</string>
</attribute>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Choix du polygone</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QRadioButton" name="triangleRadio">
<property name="text">
<string>Triangle</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroup</string>
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="QuadrilatereRadio">
<property name="text">
<string>Quadrilatère</string>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroup</string>
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="PentagoneRadio">
<property name="text">
<string>Pentagone</string>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroup</string>
</attribute>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>InputWindow</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>236</x>
<y>246</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>174</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>InputWindow</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>304</x>
<y>246</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>174</y>
</hint>
</hints>
</connection>
</connections>
<buttongroups>
<buttongroup name="colorOrTexture">
<property name="exclusive">
<bool>true</bool>
</property>
</buttongroup>
<buttongroup name="buttonGroup"/>
</buttongroups>
</ui>
输入窗口
0
0
400
256
奥布杰特酒店
假的
0
17
您是cet助理,您是积分榜上的一员,您是多功能手机的代言人,您是贴花机的一员,您是质感的一员。
真的
htmlhead/bodypChoix de la texture qui s'appliquera sur l'objet/p/BODYD/html
纹理类型
假的
HTMLHOD/BODYPSUR CHOQUIONGONE,La织构血清DE
库鲁拉迪奥
单色
真的
色彩结构
htmlhead/bodypUne图像s'APLIQUERA sur l'objet/p/body/html
形象
色彩结构
Qt::水平
40
20
多角形合唱团
三角
真的
按钮组
四边形
按钮组
五角
按钮组
Qt::水平
40
20
Qt::垂直
20
40
Qt::水平
QDialogButtonBox::取消| QDialogButtonBox::确定
钮扣盒
已接受()
输入窗口
接受
236
246
157
174
钮扣盒
拒绝()
输入窗口
拒绝
304
246
286
174
真的
编辑:添加了classe场景
场景h
#ifndef SCENE_H
#define SCENE_H
#include "light.h"
#include "svertex.h"
#include <QWidget>
#include "QAbstractButton"
#include <QObject>
#include <string>
#include <vector>
using namespace std;
enum colorOrTexture {color, texture};
inline std::istream & operator>>(std::istream & str, colorOrTexture & v) {
unsigned int a_colorOrTexture = 0;
if (str >> a_colorOrTexture)
v = static_cast<colorOrTexture>(a_colorOrTexture);
return str;
}
class Scene : public QObject
{
Q_OBJECT
protected:
//Precise if we use simple colors or if we apply textures on items
colorOrTexture mColor_or_texture;
//the number and list of vertices
int mVertexNumber;
vector<SVertex> mVertexList;
//the number of edges of the polygons (triangle ? rectangle ?)
int mPolygonType;
//the number and list of polygons.
int mIndicesSize;
vector<unsigned int> mIndices;
//The location of the observer
SVertex* mObs;
//the number and list of lights
int mLightNumber;
vector<Light> mLightList;
public:
//ask the user with a GUI the caracteristics of the scene
Scene();
//parse a file to get the caracteritics of the scene
Scene(string fileName);
//export the actual scene in a file
//void generate_file(QString fichier);
colorOrTexture getColor_or_texture();
void setColor_or_texture(colorOrTexture _Color_or_texture);
int getVertexNumber();
void setVertexNumber(int _VertexNumber);
vector<SVertex> getVertexList();
void setVertexList(vector<SVertex> _VertexList);
int getIndicesSize();
void setIndicesSize(int _IndicesSize);
vector<unsigned int> getIndices();
void setIndices(vector<unsigned int> _Indices);
int getPolygonType();
void setPolygonType(int _PolygonType);
SVertex* getObs();
void setObs(SVertex* _Obs);
virtual ~Scene();
public slots:
void setColorOrTextureFromGUI(int id);
};
#endif // SCENE_H
#如果场景不可用#
#定义场景
#包括“light.h”
#包括“svertex.h”
#包括
#包括“QAbstractButton”
#包括
#包括
#包括
使用名称空间std;
枚举颜色或纹理{颜色,纹理};
内联标准::istream&operator>>(标准::istream&str,ColortTexture&v){
无符号整数a_colorTexture=0;
如果(str>>a_colorTexture)
v=静态浇铸(颜色或结构);
返回str;
}
课堂场景:公共QObject
{
Q_对象
受保护的:
//如果我们使用简单的颜色或在物品上应用纹理,则精确
颜色或纹理颜色或纹理;
//顶点的数目和列表
int mVertexNumber;
向量mVertexList;
//多边形的边数(三角形?矩形?)
int-mPolygonType;
//多边形的数量和列表。
int mIndicesSize;
媒介思维;
//观察者的位置
斯维特克斯*暴徒;
//灯光的数量和列表
int mLightNumber;
向量列表;
公众:
//使用GUI向用户询问场景的特征
场景();
//解析文件以获取场景的特征
场景(字符串文件名);
//导出文件中的实际场景
//作废生成_文件(QString fichier);
颜色或纹理获取颜色或纹理();
void setColor_或_纹理(colorTexture\u Color_或_纹理);
int getVertexNumber();
void setVertexNumber(int\u VertexNumber);
向量getVertexList();
void setVertexList(向量_VertexList);
int getIndicateSize();
void setindicatesize(int_indicatesize);
向量getindex();
无效集合指数(向量_指数);
int getPolygonType();
void setPolygonType(int\u PolygonType);
SVertex*getObs();
无效setObs(SVertex*_Obs);
虚拟场景();
公众时段:
void setColorOrtextRefromGUI(int id);
};
#endif//SCENE_H
Scene.cpp
#include "scene.h"
#include "inputwindow.h"
#include "addpointswindow.h"
#include "addobs.h"
#include "addlights.h"
#include <fstream>
#include <iostream>
using namespace std;
Scene::Scene()
{
InputWindow window(this);
int introductionAccepted = window.exec();
if (introductionAccepted == QDialog::Accepted)
{
AddObs obsWindow;
int obsDefinitionAccepted = obsWindow.exec();
if (obsDefinitionAccepted == QDialog::Accepted)
{
AddPointsWindow pointsWindow;
int pointsWindowAccepted = pointsWindow.exec();
if (pointsWindowAccepted == QDialog::Accepted)
{
AddLights lightsWindow;
int lightsWindowAccepted = lightsWindow.exec();
if (lightsWindowAccepted == QDialog::Accepted)
{
//define scene
}
}
}
}
}
Scene::Scene(string fileName)
{
//ifstream fileStream(fileName, ios::in);
ifstream fileStream(fileName);
if(!fileStream)
{
//exception
}
int tmp;
fileStream >> tmp;
if (0 == tmp)
{mColor_or_texture = color;}
else
{mColor_or_texture = texture;
}
fileStream >> mVertexNumber;
vector<SVertex>::iterator vertexIterator;
mVertexList.resize(mVertexNumber);
for (vertexIterator = mVertexList.begin() ; vertexIterator != mVertexList.end() ; vertexIterator++ )
{
(*vertexIterator) = SVertexFromStream(fileStream);
}
// Loading polygon Type
fileStream >> mPolygonType;
// Loading Indices list, starting with size
fileStream >> mIndicesSize;
mIndices.resize(mIndicesSize);
vector<unsigned int>::iterator indexInterator;
for (indexInterator = mIndices.begin() ; indexInterator != mIndices.end() ; indexInterator++ )
{
fileStream >> (*indexInterator);
}
SVertex obs = SVertexFromStream(fileStream);
mObs = &(obs);
/* fileStream >> mLightNumber;
vector<Light>::iterator it3;
for (it3 = mLightList.begin() ; it3 != mLightList.end() ; it3++ )
{
(*it3) = Light(fileStream);
}
*/
}
Scene::~Scene()
{
}
colorOrTexture Scene::getColor_or_texture(){
return mColor_or_texture;
}
void Scene::setColor_or_texture(colorOrTexture _Color_or_texture){
mColor_or_texture = _Color_or_texture;
}
void Scene::setColorOrTextureFromGUI(int id)
{
mColor_or_texture = (id == 0) ? color : texture;
cout << "slot" << endl;
}
int Scene::getVertexNumber(){
return mVertexNumber;
}
void Scene::setVertexNumber(int _VertexNumber){
mVertexNumber = _VertexNumber;
}
vector<SVertex> Scene::getVertexList(){
return mVertexList;
}
void Scene::setVertexList(vector<SVertex> _VertexList){
mVertexList = _VertexList;
}
int Scene::getIndicesSize(){
return mIndicesSize;
}
void Scene::setIndicesSize(int _IndicesSize){
mIndicesSize = _IndicesSize;
}
vector<unsigned int> Scene::getIndices(){
return mIndices;
}
void Scene::setIndices(vector<unsigned int> _Indices){
mIndices = _Indices;
}
int Scene::getPolygonType(){
return mPolygonType;
}
void Scene::setPolygonType(int _PolygonType){
mPolygonType = _PolygonType;
}
SVertex* Scene::getObs(){
return mObs;
}
void Scene::setObs(SVertex* _Obs){
mObs = _Obs ;
}
#包括“scene.h”
#包括“inputwindow.h”
#包括“addpointswindow.h”
#包括“addobs.h”
#包括“addlights.h”
#包括
#包括
使用名称空间std;
场景::场景()
{
输入窗口(此窗口);
int introductionAccepted=window.exec();
if(已接受的介绍==QDialog::已接受)
{
AddObs-obs窗口;
int obsDefinitionAccepted=obsWindow.exec();
如果(obsDefinitionAccepted==QDialog::Accepted)
{
AddPointsWindow pointsWindow;
int pointsWindowAccepted=pointsWindow.exec();
if(pointsWindowAccepted==QDialog::Accepted)
{
AddLights lig