visual Studio 8.0  

Visual Basic에서 폴더 선택 다이얼로그 예제 입니다. 


        Dim folder As String = ""
        Dim filePath As New FolderBrowserDialog
        filePath.SelectedPath = Application.StartupPath
        If filePath.ShowDialog() = Windows.Forms.DialogResult.OK Then
            folder = filePath.SelectedPath
        End If

        Console.WriteLine(folder)










저작자 표시 비영리 변경 금지
신고

'programming > Visual Basic' 카테고리의 다른 글

폴더 선택 다이얼로그  (0) 2016.10.12

d- bus 통신 예제 입니다.

작은 창이 Send 이며


보낸 데이터는 큰창이 받아 출력하고 있습니다.






viewer

Profile 추가 내용

DBUS_ADAPTORS += org.test.xml
DBUS_INTERFACES += org.test.xml

viewer.h
#ifndef VIEWER_H
#define VIEWER_H

#include 

class Viewer : public QObject
{
    Q_OBJECT

    Q_PROPERTY(int number READ number NOTIFY numberChanged)

signals:
    void onchanged();
    void numberChanged(int n);

public:
    Viewer(QObject *parent = 0);
    int number();


public slots:

    void getNumber(int number);


private:
    int getnumber = 0;

};

#endif // VIEWER_H


viewer.cpp
#include "viewer.h"

#include 
#include 

#include "chat_adaptor.h"
#include "chat_interface.h"

Viewer::Viewer(QObject *parent)
{
    QDBusConnection::sessionBus().registerObject("/", parent);

    org::example::chat *iface;

    iface = new org::example::chat(QString(), QString(),  QDBusConnection::sessionBus(), parent);

    connect(iface, SIGNAL(message(int)), this, SLOT(getNumber(int)));
}

void Viewer::getNumber(int number)
{
    getnumber = number;

    qDebug() << "getnumber :" << getnumber;

    emit numberChanged(number);
}


int Viewer::number()
{
    return getnumber;
}


main.cpp
#include 
#include 

#include 
#include 

#include "viewer.h"

int main(int argc, char *argv[])
{
    QGuiApplication app(argc, argv);

    QQmlApplicationEngine engine;

    engine.load(QUrl(QStringLiteral("qrc:/main.qml")));


    Viewer viewer(app.focusObject());

    engine.rootContext()->setContextProperty("mw", &viewer);

    return app.exec();
}

main.qml
import QtQuick 2.3
import QtQuick.Controls 1.2





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


    Label {
        id: lablel
        text: mw.number;
        anchors.centerIn: parent


    }

}


Data send

send.h

#ifndef SEND_H
#define SEND_H

#include
#include 
#include 


class WorkerThread : public QThread
{

    Q_OBJECT

    void run();

};



class SEND :public QObject
{
    Q_OBJECT

    Q_PROPERTY(int number READ number NOTIFY numberChanged)


signals:
    void numberChanged();

public:
    explicit SEND(QObject *parent = 0);

    void careateRandomNumber();

    void send();
//    void dbusConnection();

    int number();

public slots:
    int randnumber();
    void update();

private:
    int rand;
    QDBusMessage msg;
};

#endif // SEND_H







send.cpp
#include 
#include 
#include 

#include "send.h"

SEND::SEND(QObject *parent)
{

    careateRandomNumber();

    QTimer *timer = new QTimer(this);
    connect(timer, SIGNAL(timeout()), this, SLOT(update()));
    timer->start(1000);

//    WorkerThread t;
//    t.start();

}

void SEND::careateRandomNumber()
{

    QTime now = QTime::currentTime();
    qsrand(now.msec());

    rand = qrand();
}

void SEND::send()
{
    careateRandomNumber();

    if (QDBusConnection::sessionBus().isConnected()) {

        msg = QDBusMessage::createSignal("/", "org.example.chat", "message");
        qDebug() << "send message : " << rand;

        msg << rand;
        QDBusConnection::sessionBus().send(msg);
        emit numberChanged();
   
    }

}

void SEND::dbusConnection()
{


    QDBusConnection::sessionBus().registerObject("/", this);


    if (QDBusConnection::sessionBus().isConnected()) {
        msg = QDBusMessage::createSignal("/", "org.example.chat", "message");

    }
}

int SEND::number()
{
    return rand;
}

int SEND::randnumber()
{
    return rand;
}

void SEND::update()
{

    send();

}

void WorkerThread::run()
{
      qDebug()<<"From worker thread: ";
}



main.cpp
#include 
#include 
#include 

#include "send.h"

int main(int argc, char *argv[])
{
    QGuiApplication app(argc, argv);

//    qmlRegisterType ("Send", 1,0, "SendClass");


    QQmlApplicationEngine engine;
    engine.load(QUrl(QStringLiteral("qrc:/main.qml")));


//    Viewer viewer(app.focusObject());

    SEND send(app.focusObject());

    engine.rootContext()->setContextProperty("send", &send);


    return app.exec();
}



main.qml
import QtQuick 2.3
import QtQuick.Window 2.2
import QtQuick.Controls 1.3

Window {
    id :root

    visible: true

    MouseArea {
        anchors.fill: parent
        onClicked: {
            Qt.quit();
        }
    }


    Text {
        id : sendnumber
        text: send.number
        anchors.centerIn: parent
    }


}




저작자 표시 비영리 변경 금지
신고

'programming > Qt' 카테고리의 다른 글

Qt d-bus 예제  (0) 2016.02.11
Virtualbox 에서 QtCreator 실행  (0) 2016.02.02
qml signal /slot  (0) 2015.09.25
qmlRegisterType  (0) 2015.09.14
여러개의 파일 확장자 변경 유틸리티  (0) 2012.07.03
Qt [UI] css를 이용한 버튼 효과주기  (0) 2012.06.07

+ Recent posts