Monthly Archives: April 2017

eclipse – map jar to source

As we know when we develop java, some special jar should be stepped into to investigate logical inside jar.

say there are 10 jar files has 10 zip file for source.

there is a better way to use eclipse UI. Here is inside .classpath file.

1
<classpathentry kind="lib" path="D:/dev/oltu/oauth-2.0/authzserver/target/org.apache.oltu.oauth2.authzserver-1.0.3-SNAPSHOT.jar" sourcepath="D:/dev/oltu/oauth-2.0/authzserver/src/main/java/org.zip"/>

Maven – different between -DskipTests and -Dmaven.test.skip=true

sometime when we build maven, junit will also be invoked to test code.

usually, these unit test will fail because of development machine configures are different.

there are two commands which could skip test.

1
2
$ mvn package -DskipTests
$ mvn package -Dmaven.test.skip=true

“-DskipTests” is to build test source code but don’t run them.
“-Dmaven.test.skip=true” don’t do anything for test source code, do not compile and do not run for test code.

Qt – ListView SetModel tip

when developing qt, QStringList should be display on ‘ui->listView’, However, following code won’t work.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
...
    QDir myDir("C:\\");
 
    QStringList filter("*");
    QStringListModel model;
    QStringList filesList = myDir.entryList(QStringList(filter),QDir::Files | QDir::Dirs);
    model.setStringList(filesList);
    ui->listView->setModel(&model);
...
}

because ‘model’ object will be delete after function is done.

ui->listView will not be able to get model object.

move to MainWindow ‘model’ to MainWindow declare will be good.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
 
class MainWindow : public QMainWindow
{
    Q_OBJECT
 
public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();
    QStringListModel model;
private:
    Ui::MainWindow *ui;
};
 
 
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
...
    QDir myDir("C:\\");
 
    QStringList filter("*");
 
    QStringList filesList = myDir.entryList(QStringList(filter),QDir::Files | QDir::Dirs);
    model.setStringList(filesList);
    ui->listView->setModel(&model);
...
}