21 QHBoxLayout* layout =
new QHBoxLayout;
22 layout->setContentsMargins(0, 0, 0, 0);
23 layout->setSpacing(0);
25 this->setLayout(layout);
28 QLabel* name =
new QLabel();
30 name->setFixedSize(100, 18);
31 QFontMetrics fontMetrics(name->font());
32 QString elide = fontMetrics.elidedText(str, Qt::ElideRight, 100);
35 name->setToolTip(str);
40 layout->addWidget(name, 0);
42 layout->setSpacing(3);
64 QHBoxLayout* layout =
new QHBoxLayout;
65 layout->setContentsMargins(0, 0, 0, 0);
66 layout->setSpacing(0);
68 this->setLayout(layout);
71 QLabel* name =
new QLabel();
73 name->setFixedSize(100, 18);
74 QFontMetrics fontMetrics(name->font());
75 QString elide = fontMetrics.elidedText(str, Qt::ElideRight, 100);
78 name->setToolTip(str);
83 QPushButton* open =
new QPushButton(
"Open");
87 open->setFixedSize(60, 24);
89 layout->addWidget(name, 0);
91 layout->addWidget(open, 2);
92 layout->setSpacing(3);
96 connect(open, &QPushButton::clicked,
this, [=]() {
101 QString path = QFileDialog::getExistingDirectory(
this, tr(
"Open File"), QString::fromStdString(getAssetPath()), QFileDialog::ReadOnly);
102 if (!path.isEmpty()) {
104 path = QDir::toNativeSeparators(path);
108 QMessageBox::warning(
this, tr(
"Path"), tr(
"You do not select any path."));
112 QString path = QFileDialog::getOpenFileName(
this, tr(
"Open File"), QString::fromStdString(getAssetPath()), tr(
"Text Files(*.*)"));
113 if (!path.isEmpty()) {
115 path = QDir::toNativeSeparators(path);
117 if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
118 QMessageBox::warning(
this, tr(
"Read File"),
119 tr(
"Cannot open file:\n%1").
arg(path));
126 QMessageBox::warning(
this, tr(
"Path"), tr(
"You do not select any file."));