반응형



안드로이드에서 버튼을 눌르고 있을때 이벤트 주기 


        button_03.setOnTouchListener(new View.OnTouchListener() {

@Override

public boolean onTouch(View v, MotionEvent event) {

int action = event.getAction();

if(MotionEvent.ACTION_DOWN == action){

onHandlerUp();

}else if(MotionEvent.ACTION_UP == action){

mHandler.removeCallbacks(r);

}

return true;

// TODO Auto-generated method stub

// return false;

}

});



    private Runnable r;

    private void onHandlerUp() {

mHandler = new Handler();

r = new Runnable() {

@Override

public void run() {

tc = new TCP_Client();

 

 myTaskParams = "2";

 

     tc.execute(myTaskParams);

mHandler.postDelayed(r, 100);

}

};

mHandler.postDelayed(r, 20);

}




메인 스레드                       서브 스레드

UI  관런 변경         <===>    작업수행 


안드로이드는 메인 스레드 (백그라운드에서 ui) 변경시키면 에러 발생 

서로 변경 하는것을 허용하게 되면 동기화 문제 발생     

핸들러를 이용하여 스레드간에 통신 할수 있도록 함.



postDelayed(mRunnable, 1000); // mRunnable 객체를 1초 뒤에 실행



반응형

'programming' 카테고리의 다른 글

델파이 포인터 예제  (0) 2020.03.26
소캣 함수  (0) 2014.12.23
TCP 소켓의 기초  (0) 2014.12.23
Socket accept()호출 Invalid 에러  (0) 2014.12.18
반응형









accept 이전에 lilen을 addr

 초기화해야 함

platform에 따라 다름. 


예)

        client_len = sizeof(clientaddr);

        client_sockfd = accept(server_sockfd, (struct sockaddr *)&clientaddr, &client_len); 

반응형

'programming' 카테고리의 다른 글

델파이 포인터 예제  (0) 2020.03.26
소캣 함수  (0) 2014.12.23
TCP 소켓의 기초  (0) 2014.12.23
안드로이드 버튼 눌르고 있을때 처리 이벤트  (0) 2014.12.18
반응형






변수는 프로그램을 실행 되는 동안 데이터를 가지고 있는 곳 어떤 책에서는 변수는 정보를 저장하는 장소라고 되어 있다.

저장하는 장소 즉 메모리이다.

위 스크린샷에서 변수는 a 와 b 가된다. 

a 에는 1을 넣었고  b 에는 2를 넣었다.


우선 자세한 설명은 나중에 하기로 하고 중요한 포인트는 cout은 출력할때 쓰인다는 것과 a와 b는 변수다.라는 것만 확인! 

즉   출력 <<  1 + 2 << 다음줄;   쫌 이상하지만 이렇게 이해하시면 되며  출력 << a + b << 다음줄;  

a.out 으로 결과를 출력해보면 3이 출력이 된다. 

즉  a 와 b는 int (integer) 형 변수이다. 




반응형
반응형


책을 보다 보니


**************************

*   Hello,  이름                 *

**************************

를 보니 구현해보라는 장이 나왔고  이쯤이야 하면서 

string hello = "Hello, ";

    string input;
    cout << "Please enter your first name : ";
    cin >> input;
    for(int i = 0; i < input.size()+hello.size() + 4; i++){
        cout << "*";
    }
    cout << endl;
    cout << "* "<<hello << input <<" *"<<endl;
    for(int i = 0; i < input.size()+hello.size() + 4; i++){
        cout << "*";
    }

cout << endl;

로 구현하였다 .


책에 내용에서 의 코딩방법은

cout << "Please enter your first name : ";
string naem; cin >> name;

const string greetin = " Hello, " + name + "!";

const string spaces(greeting.size() ' ');

const string second = "* " + spaces + " *";

const string first(second.size(),'*');


const string first(second.size(),'*');

위와같은 방법으로하면 for문대신 간단히 처리할 수 있었다.



....좀더 분발하자...






반응형
반응형

폴더 확장자 변경 유틸리티

다운받기 - > rename.rar





사용방법

1. 확장자를 변경할곳을 지정 

2. before   변경할 확장자
3. after 변경을 원하는 확장자

ok 클릭



반응형

'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
Qt [UI] css를 이용한 버튼 효과주기  (0) 2012.06.07
반응형

1. 프로젝트를 생성하고 
우선 Resources 에 그림파일추가 


mainwindow.ui 를 클릭하여 Design 폼으로 이동

PushButton에서 우클릭! 

change stylesheet...  클릭!



텍스트 창에서 우클릭 하여 

border-image간단히 추가할 수 있다.


QPushButton:disabled

QPushButton:hover

QPushButton:pressed

사용 예제 

QPushButton {

border: 7px ;   

border-image: url(:/img/button/D:/Work/img/button/button.png) 7 7 7 7;

padding: -7px;

}

QPushButton:disabled{

border-image: url(:/img/button/D:/Work/img/button/button-disabled.png) 7 7 7 7;

}

QPushButton:hover{

border-image: url(:/img/button/D:/Work/img/button/button-hover.png) 7 7 7 7;

}

QPushButton:pressed{

border-image: url(:/img/button/D:/honam/Work/img/button/button-pressed.png) 7 7 7 7;

}


padding: -7px;    하면  버튼size가 작아졌을 때 글씨가 잘려 보이지 않는다 .

border-image : 이미지url   top right bottom left ;   로 되어 있음!

버튼에 마우스 올리기전 


버튼에 마우스를 올린 후 

이렇게 간단히 버튼의 효과를 줄 수 있다. 




반응형

'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
반응형





링크드 리스트 소스 구연했던 예제입니다. 


구연 다안되어 있지만.. 


참고 하실분은 참고 하세요.


list.h

#ifndef LIST_H

#define LIST_H
#include <node.h>
class List
{
public:
    List(){
        std::cout<<"list :1";
       _head=NULL;
    }

    List(Node *appendNode){
        std::cout<<"list :2";
    }

    Node *headNode() const;
    Node *appendNode(const std::string &text);
    Node *insertNode(const std::string &text, Node *beforeNode);
    Node *deleteNode(Node *node); //삭제

    void print();


private:
    Node *_head;
};


#endif // LIST_H


list.cpp


#include "list.h"
#include <iostream>



Node *List::appendNode(const std::string &text)
{

    Node *newNode = new Node(text);

    if (!_head) {
        std::cout<<"\nappendNode : _head=null";
        _head=newNode;
        _head->text();

    } else {
        std::cout << "_head : NULL 아님 ";
        Node *ptr =_head;
        while(ptr->next())
            ptr =ptr->next();
        ptr->_next=newNode;
        newNode->_prev=ptr;
    }
    return newNode;
}

Node *List::headNode() const{

    return _head;

}
void List::print(){

    for(Node *ptr=_head;ptr;ptr=ptr->next()){
        ptr->text();
    }

}

 Node *List::deleteNode(Node *node){
     Node *next = node->next();
     if(node->_prev)
     {
        node->_prev->_next=node->_next;

     }
     if(node->_next){
         node->_next->_prev=node->_prev;
     }
     if(!node->prev()){
         _head=next;
     }
     delete node;

     return next;

 }




node.h

#ifndef NODE_H
#define NODE_H
#include <iostream>
#include <string>


class Node
{
    friend class List;
private:

    Node(){
        this->setText("");
        std::cout<<"\nin?";
        this->text();
        _prev=0;
        _next=0;
    }

    Node(std::string str){
        _prev=0;
        _next=0;
        _str=str;
        std::cout<< "\n 기본생성자 아님"<< _str;
    }

public:

    std::string text() const;
    void setText(const std::string &text);

    Node *next() const;
    Node *prev() const;

private:

    Node *_prev;
    Node *_next;
    std::string _str;
};

#endif // NODE_H



node.cpp


#include "node.h"

void Node::setText(const std::string &text){

//    if(text==""){
//        std::cout<<"없음";
        _str=text;
//    }

}


std::string Node::text() const
{


    std::cout<< "\nNode str  :"<< _str<<"\n";
    return _str;


}




Node *Node::prev() const
{
    return this->_prev;
}


Node *Node::next() const
{
    return this->_next;
}







main.cpp


#include <iostream>
#include <list.h>
#include <node.h>

using namespace std;

int main()
{
    int select=0;
    std::string data="";

    List lt,lt2;

    while(true){

        cout << "================"<<"\n";
        cout << "1   노드 추가 \n";
        cout << "2   노드 보기 \n";
        cout << "3   노드 삽입 \n";
        cout << "4   노드 삭제 \n";
        cout << "5   다음 노드 \n";
        cout << "6   이전 노드 \n";
        cout << "================"<<"\n";
        cout << "?  ";
        cin >>select;

        cout << "\n";

        switch(select){

        case 1:{
            cout << " 추가할 노드의 이름 ?   ";
            cin >>data;
            cout <<"\n";

            lt.appendNode(data);
            break;
        }
        case 2:

            lt.print();
            break;

        case 3:
        {

            break;
        }

        case 4:{
            int _data;
            std::cout << "삭제할 노드 ?";
            std::cin >> _data;
            Node *node = lt.headNode();
            if(!node){
                std::cout<<"null ";
                break;
            }
            for(int i = 1; i<_data;i++)
            {

                node = node->next();
                if(!node){
                    std::cout<<"null ";
                    break;
                }
            }

            lt.deleteNode(node);
            break;
        }
        case 5:
            break;
        case 6:
            break;

        default:
            break;

        }



    }

    return 0;
}






반응형
반응형

#include <iostream>

using namespace std;

//간략... 네임 스페이스는 명칭의 선언 영역을 분리하여 충돌을 방지한다.

//  자세한 설명은 http://www.winapi.co.kr/clec/cpp3/34-1-3.htm

자세히 설명되어 있네요 .


//과일이라는 클래스를 만들었습니다.
class fruit{

private :       // 공개안함!!!

   int apple;         
   int strawberry;

public :     //공개

   void Setfruit(int apple_arg,int strawberry_arg);  // 선언정도 우선 생각하세요 ..
   int getApple(void);     //  사과의 개수를 가지고 오기 만들었어요
   int getstrawberry(void);  //딸기의 개수를 가지고 오기 만들었어요..
};

//위에 선언한 void Setfruit를 사용할꺼에요 .

//값을 넣는곳! 이라고  우선 단순히!!  생각하세요!

void fruit::Setfruit(int apple_arg,int strawberry_arg){

//받은 값을 사과라는 변수에 넣는 작업!!
   apple=apple_arg;

//받은 값을 딸기 라는 변수에 넣는 작업!!
   strawberry=strawberry_arg;
}

//사과의 개수가 몇개인지 그냥 리턴해 주는 곳
int fruit ::getApple(void)
{

   return apple;

}

//딸기의 개수가 몇개인지 그냥 리턴해 주는 곳
int fruit::getstrawberry(void){
   return strawberry;
}

int main()
{


   fruit box1,box2; //과일의 객체생성!!!

//box1 이라는  박스와 box2 이라는 곳에 과일을 담을 꺼에요


   box1.Setfruit(20,30); 

// box1 박스에 사과 20개와 딸기 30개를 담는다고 하였습니다.

//그러면 Setfruit(int apple_arg,int strawberry_arg)   멤버함수에 들어가  

//apple=apple_arg;    사과의 개수가 20개가 됩니다.   

   box2.Setfruit(50,0);

//위와 동일합니다. box2에 설정한 값입니다.


   cout<< "박스1\n";
   cout<<"사과 개수" <<box1.getApple()<< " , "<< box1.getstrawberry();

//box1에 getApple() 하여 사과개수가 몇개 인지 불러오고 있습니다.

//나머지도 동일합니다.

   cout <<"\n";

   cout<< "박스2\n";
   cout<<"사과 개수" <<box2.getApple()<< " , "<< box2.getstrawberry();

   cout <<"\n";


   return 0;
}




반응형

+ Recent posts