小编Jeg*_*ggu的帖子

如何更改列或行中项目之间的间距

我正在调整Item使用ColumnRow键入QML.有没有办法给每个人留出不同的间距Item.以下内容:

喜欢:

ITEM1

间距:10

ITEM2

间距:20

项目3

间距:40

ITEM4

这是我的代码:

ApplicationWindow {
    visible: true
    width: 640
    height: 480
    title: qsTr("Hello World")

    Rectangle{
        id: rect
        anchors.fill: parent

        Column{
            id: column
            anchors.centerIn: parent
            spacing: 10

            Row{
                id: row1
                anchors.horizontalCenter:  parent.horizontalCenter
                Rectangle{
                    width: 300
                    height: 100
                    color: "lightgreen"
                }
            }
            Row{
                id: row2
                anchors.horizontalCenter:  parent.horizontalCenter
                Rectangle{
                    width: 100
                    height: 50
                    color: "lightblue"
                }
            }
            Row{
                id: row3
                anchors.horizontalCenter:  parent.horizontalCenter
                Rectangle{
                    width: 50
                    height: 50 …
Run Code Online (Sandbox Code Playgroud)

qml qt5 qtquick2

5
推荐指数
1
解决办法
3293
查看次数

如何使用索引访问ListView中的委托属性

我想访问委托属性ListView.我试过contentItem但有时它是undefined.

这是我的代码:

ListModel{
            id: modeldata
            ListElement{
                name:"don"
                rank:1
            }
            ListElement{
                name:"shan"
                rank:2
            }
            ListElement{
                name:"james"
                rank:3
            }
            ListElement{
                name:"jeggu"
                rank:4
            }
        }
        Component{
            id: delegateitem
            Row {
                property int count: rank
                Rectangle{
                    width: 100
                    height: 50
                    Text{
                        anchors.centerIn: parent
                        text: name
                    }
                }
            }
        }
        ListView{
            id: listview
            focus: true
            anchors.fill: parent
            model: modeldata
            delegate: delegateitem
            onCurrentIndexChanged: {
        console.log("position",currentIndex)
        console.log("property",contentItem.children[currentIndex].count);
            }
        }
Run Code Online (Sandbox Code Playgroud)

在位置1处出现无效输出问题

qml: position 0
qml: property 1
qml: position 1
qml: property …
Run Code Online (Sandbox Code Playgroud)

qml qt5 qtquick2

3
推荐指数
1
解决办法
1万
查看次数

主Makefile中的未定义引用

我在linux中做了一个示例项目但是在运行main Makefile时遇到错误

项目信息:

项目/数据库文件夹,包含文件database.h,database.cpp,bulid-database,Makefile

database.h

/*data base file*/
#include<iostream>
using namespace std;
class mydatabase
{
public:
    mydatabase(int a , int b);
    int sum(){return m_a +m_b;}
    int diff(){return m_a -m_b;}
    int mul(){return m_a *m_b;}
    float div(){return m_a /m_b;}
    int reminder(){return m_a %m_b;}

private:
    int m_a , m_b;
};
Run Code Online (Sandbox Code Playgroud)

database.cpp

#include "database.h"
mydatabase::mydatabase(int a ,int b):m_a(a) , m_b(b)
{
}
Run Code Online (Sandbox Code Playgroud)

bulid数据库

make
if [ -f libdatabase.a ];
then
   echo "Database-Library Build Success"
   cp libdatabase.a ../LIBs/
else
    echo "databse-Library Build Failure"
fi …
Run Code Online (Sandbox Code Playgroud)

c++ linux makefile

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

TextFiled的安全文本输入

我使用textfiled进行密码输入和echomode密码.但我希望它应该在进入和一段时间(一秒)后显示字符或进入下一个字符它应该转到星号.

码:

TextField {
        id: inputtext
        height: parent.height
        width:parent.width
        font.family: "Helvetica"
        horizontalAlignment: TextInput.Center
        font.pointSize:  Math.round(28 * (main.height/1080))
        placeholderText:"Password"
        echoMode:TextInput.Password
    }
Run Code Online (Sandbox Code Playgroud)

我尝试使用文本项,显示当前输入键一段时间后,我将使其不可见,并根据光标位置移动文本项.码:

TextField {
    id: inputtext
    anchors.centerIn: parent
    width: 200
    height: 20
    echoMode:TextInput.Password
    Text{
        id: showpwd
        text: "h"
        font.pointSize: 10
        verticalAlignment: Text.AlignVCenter
    }
    onTextChanged: {
        showpwd.x = cursorPosition*7
        showpwd.text = text.charAt(cursorPosition-1);

    }
}
Run Code Online (Sandbox Code Playgroud)

问题:我仍然可以在文本项后面查看星号.有人可以帮我解决这个问题.

qt qml qtquick2

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

纹理在Qt中缩放而不是重复

我刚开始在qt中使用opengl,使用纹理我在quard中显示图像.

然后我将gltexture包装模式设置为gl_repeat但不重复.

我甚至试过gl_clamp_to_edge仍然无法正常工作.

图像大小256*256

码:

GLuint _textureId; //The id of the texture
int _wdth;
int _hight;
void LoadGLTextures( const char * name )
{
    QImage img;

    if(!img.load(name)){
        qDebug() << "ERROR in loading image";
    }

    QImage t = QGLWidget::convertToGLFormat(img);

    _wdth = t.width();
    _hight = t.height();
    qDebug()<<"width = "<<_wdth<<"height ="<<_hight;
    glGenTextures(1, &_textureId);
    glBindTexture(GL_TEXTURE_2D, _textureId);
    glTexImage2D(GL_TEXTURE_2D, 0, 3, t.width(), t.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, t.bits());

    glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);

    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); …
Run Code Online (Sandbox Code Playgroud)

c++ opengl qt

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

标签 统计

qml ×3

qtquick2 ×3

c++ ×2

qt ×2

qt5 ×2

linux ×1

makefile ×1

opengl ×1