无论如何我们可以有自定义布局,例如https://doc.qt.io/archives/qt-4.7/examples-layouts.html中定义的
Qt设计师内部?
在Qt Designer中添加此类自定义布局的过程是什么?任何人都可以指导在Qt Designer中进行此类自定义增强所涉及的步骤.
我有一个JSON模型,我填充它QTreeView:
*-group1
| |
| *-item1 value1
| |
| *-item2 value2
|
*-group2
|
*-item4 value3
Run Code Online (Sandbox Code Playgroud)
现在我想禁用选择groups,以便用户只能选择行items.我想在不修改模型的情况下实现它.
在 C++11 中,我可以通过这种方式获得参数的聚合大小:
template<typename First, typename... Rest>
size_t getSize( const First& first, const Rest& ...rest )
{
return getSize(first) + getSize( rest... );
}
template <typename T>
size_t getSize( const T& )
{
return sizeof(T);
}
std::cout << "Size of arguments is: " << getSize( short(0), double(0.0) ) << std::endl;
Run Code Online (Sandbox Code Playgroud)
输出将是:“参数的大小是:10”。旧的 C++ 有什么类比吗?
PS 也欢迎 C++11 更好的解决方案
在我的程序中,我使用2个纹理:t0和t1.t1是附加的,仅在某些情况下需要:
.....
glActiveTexture ( GL_TEXTURE1 );
if ( mDisplayMode == EDM_DEFAULT ){
glBindTexture( GL_TEXTURE_2D, 0 ); // In this case I don't need t1
}else{
glBindTexture( GL_TEXTURE_2D, mglDegreeTexture ); // In this case t1 will overlap t0
}
shader->setUniformValue( "textureId1", 1 );
Run Code Online (Sandbox Code Playgroud)
绘图着色器:
.....
vec4 c1 = texture( textureId0, uv );
vec4 c2 = texture( textureId1, gridUV );
float a = c2.a;
gl_FragColor = ( 1.0 - a )*c1 + a*c2;
Run Code Online (Sandbox Code Playgroud)
它工作正常:第二个纹理在需要时首先重叠.假设使用glBindTexture(..,0)返回零纹理(0,0,0,0),但在将NVidia驱动程序更新为314.07之后,我的代码生成黑屏,就像glBindTexture(..,0)返回(0,0) ,0,1)纹理.
我执行一些测试:使用着色器
....
vec4 c1 = texture( textureId0, …Run Code Online (Sandbox Code Playgroud) 我有一个自定义存储,我想实现ListModel以QComboBox. 为简单起见,让我们假设我们有一个int模型数据列表,所以这是我的模型和测试程序的实现:
#include <QApplication>
#include <QDebug>
#include <QAbstractListModel>
#include <QComboBox>
#include <QHBoxLayout>
#include <QPushButton>
QList<int> list;
class MyModel : public QAbstractListModel
{
public:
MyModel( QWidget* parent ):
QAbstractListModel( parent )
{}
~MyModel()
{
qDebug() << __FUNCTION__;
}
QVariant data(const QModelIndex &index, int role) const
{
if ( !index.isValid() )
return QVariant();
if ( ( role == Qt::DisplayRole ) && ( index.row() < list.size() ) )
return QString::number( list.at( index.row() ) );
return QVariant();
} …Run Code Online (Sandbox Code Playgroud)