是否有人熟悉如何解析csv文件并将其放入字符串列表中.现在我正在整个csv文件并放入字符串列表.我想弄清楚是否有办法只获得第一列.
#include "searchwindow.h"
#include <QtGui/QApplication>
#include <QApplication>
#include <QStringList>
#include <QLineEdit>
#include <QCompleter>
#include <QHBoxLayout>
#include <QWidget>
#include <QLabel>
#include <qfile.h>
#include <QTextStream>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QWidget *widget = new QWidget();
QHBoxLayout *layout = new QHBoxLayout();
QStringList wordList;
QFile f("FlightParam.csv");
if (f.open(QIODevice::ReadOnly))
{
//file opened successfully
QString data;
data = f.readAll();
wordList = data.split(',');
f.close();
}
QLabel *label = new QLabel("Select");
QLineEdit *lineEdit = new QLineEdit;
label->setBuddy(lineEdit);
QCompleter *completer = new QCompleter(wordList);
completer->setCaseSensitivity(Qt::CaseInsensitive); //Make …Run Code Online (Sandbox Code Playgroud) 我试图在退出之前提示用户确认他们想要关闭程序.如果任务仍在执行中,我想确认仍然希望退出或让他们有机会在退出之前完成任务.我使用了setOnCloseRequest,但它没有用.我使用了event.consume,似乎只是禁用了[x]按钮.任何建议表示赞赏.我在这里发现了一个类似的问题对我不起作用 - > 没有函数的JavaFX stage.setOnCloseRequest?
Public class Sample extends Application {
@Override
public void start(Stage stage) throws Exception {
stage.setOnCloseRequest(event -> {
NewScanView checkScan = new NewScanView();
boolean isScanning = checkScan.isScanning();
Alert alert = new Alert(AlertType.CONFIRMATION);
alert.setTitle("Close Confirmation");
alert.setHeaderText("Cancel Creation");
alert.setContentText("Are you sure you want to cancel creation?");
if (isWorking == true){
Optional<ButtonType> result = alert.showAndWait();
if (result.get() == ButtonType.OK){
stage.close();
}
if(result.get()==ButtonType.CANCEL){
alert.close();
}
}
});
stage.setHeight(600);
stage.setWidth(800);
stage.setTitle("Title");
stage.show();
}
public static void main(String[] args) {
launch(args);
} …Run Code Online (Sandbox Code Playgroud) 我试图从一个文件读取并进入文本编辑,它一直说QIODevice :: read:device not open..txt文件与我的.qrc和.cpp文件位于同一位置.我是在线跟踪分步指南.根据我的理解,当他们从第四季度到第五季度时,他们改变了一些东西.有没有人对我如何解决这个问题有任何暗示.谢谢
//My findstuff.h
#ifndef FINDSTUFF_H
#define FINDSTUFF_H
#include <QWidget>
namespace Ui {class FindStuff;}
class FindStuff : public QWidget{
Q_OBJECT
public:
explicit FindStuff(QWidget *parent = 0);
~FindStuff();
private slots:
void on_goButton_clicked();
private:
Ui::FindStuff *ui;
void getTextFile();
};
Run Code Online (Sandbox Code Playgroud) 我正在试图弄清楚如何在Qt中启动Windows应用程序.我想要完成的是让用户点击按钮并打开记事本窗口应用程序.我知道它们是Qt中的记事本功能,但我寻找一种不同的方式来做到这一点.我希望能够在任何Windows应用程序中执行此操作.有没有人对我如何做到这一点有任何暗示?