我是Qt的新人。
当我编译下面的代码时,我收到错误"来自' int'的无效转换Qt ::对齐标记' -tpermissive in Qt" / 1 / , / 2 / , / 3 / , / 4 / 和/ 5 / 行。
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QtWidgets>
MainWindow::MainWindow() {
createGridGroupBox();
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout -> addWidget(gridGroupBox);
setLayout(mainLayout);
setWindowTitle(tr("Layout Örneği"));
resize(600,600);
}
void MainWindow::createGridGroupBox() {
QHBoxLayout *layout = new QHBoxLayout;
gridGroupBox = new QGroupBox(tr("Grid Layout"));
label1 = new QLabel(tr("Kaynak Resmin Yolu: ").arg(1));
layout -> addWidget(label1, 0, 0);
lineEdit1 = new QLineEdit;
/*1*/ layout -> addWidget(lineEdit1, 0, 1);
label2 = new QLabel(tr("Kaynak Resmin Görseli: ").arg(2));
layout -> addWidget(label2, 1, 0);
/*label3 = new QLabel(tr("Şablon Resmin Yolu: ").arg(3));
layout -> addWidget(label3, 2, 0);*/
label4 = new QLabel(tr("Şablon Resmin Yolu: ").arg(4));
layout -> addWidget(label4, 3, 0);
lineEdit2 = new QLineEdit;
/*2*/ layout -> addWidget(lineEdit2, 3, 1);
label5 = new QLabel(tr("Şablon Resmin Görseli: ").arg(5));
layout -> addWidget(label5, 4, 0);
/*label6 = new QLabel(tr("Kaynak Resmin Yolu: ").arg(6));
layout -> addWidget(label6, 5, 0);*/
label7 = new QLabel(tr("Şablon Eşleştirme İşleminin Sonucunun Görseli: ").arg(7));
/*3*/ layout -> addWidget(label7, 0, 2);
/*label8 = new QLabel(tr("Şablon Eşleştirme İşleminin Sonucunun Görseli: ").arg(8));
layout -> addWidget(label8, 1, 2, 4, 1);*/
/*4*/ label9 = new QLabel(tr("Sonuç: ").arg(9));
layout -> addWidget(label9, 2, 2);
lineEdit3 = new QLineEdit;
/*5*/ layout -> addWidget(lineEdit3, 2, 3);
gridGroupBox -> setLayout(layout);
}
答案 0 :(得分:0)
错误是预料之中的。
addWidget()
类的QHBoxLayout
函数定义为:
void addWidget(QWidget * widget, int stretch = 0, Qt::Alignment alignment = 0)
也许您的意思是使用QGridLayout
?