Esempio n. 1
0
void MainWindow::on_pushButton_clicked()
{   fname = QFileDialog::getOpenFileName(this, tr("Open File"),0,0);
    ui->label_3->setText("Calculating...");
    QThread *thread = new QThread;  // создаём поток... вначале он создаётся остановленным

    MyClass *job = new MyClass; // создаём экземпляр нашего класса
    job->moveToThread(thread);

    if(ui->rb_MD5->isChecked()){

        connect(thread,SIGNAL(started()),job,SLOT(MyCalcMD5())); // когда поток стартует, то начать выполнение работы нашего класса
        connect(job,SIGNAL(sendString(QString)),ui->lineEdit_2,SLOT(setText(QString)));
    }
    if(ui->rb_G2012->isChecked()){
       connect(thread,SIGNAL(started()),job,SLOT(GOST2012()));
       connect(job,SIGNAL(sendString(QString)),ui->lineEdit,SLOT(setText(QString)));
    }
    if(ui->rbSha256->isChecked()){
       connect(thread,SIGNAL(started()),job,SLOT(MyCalcSha256()));
       connect(job,SIGNAL(sendString(QString)),ui->lineEdit_3,SLOT(setText(QString)));
    }
    connect(job,SIGNAL(finished()),thread,SLOT(quit())); // когда работа будет завершена, завершить поток
            connect(job,SIGNAL(finished()),job,SLOT(deleteLater())); // когда работа будет завершена, удалить наш экземпляр класса
            connect(thread,SIGNAL(finished()),thread,SLOT(deleteLater())); // когда поток остановится, удалить его
thread->start();
connect(job,SIGNAL(change_value(int)),ui->progressBar_2,SLOT(setValue(int)));
connect(job,SIGNAL(set_max(int)),ui->progressBar_2,SLOT(setMaximum(int)));
connect(job,SIGNAL(sendStringDone(QString)),ui->label_3,SLOT(setText(QString)));
connect(job,SIGNAL(sendStringFileName(QString)),ui->label_2,SLOT(setText(QString)));

}
Esempio n. 2
0
int main() {
  cout << "hi, there!" << endl;
  
  MyClass m;
  int x = m.DoubleMyStuff(10);
  cout << x << endl;
}
Esempio n. 3
0
int main() {
	MyClass a;
	a.print();
	MyClass b(199, 100);
	b.print();
	return 0;
}
Esempio n. 4
0
        void _run() {
            
            foo::Bar b;
            ASSERT( b.a );
            
            MyClass::z = false;

            {
                MyClass x;
                ASSERT( x.a );
                ASSERT( x.b );
                ASSERT( ! x.thing() );
            }
            
            ASSERT( MyClass::z );

            {
                MyClass x(5);
                ASSERT( x.a );
                ASSERT( x.b );
                ASSERT( ! x.thing() );
            }
            
            ASSERT( ! mongo::inConstructorChain() );
        }
Esempio n. 5
0
int main()
{
    unique_ptr<MyClass> ptr3(new MyClass(33)), ptr4(new MyClass(44));
    auto_ptr<MyClass> ptr1(new MyClass(1));
    auto_ptr<MyClass>ptr2(new MyClass(2));
    ptr1->myFunc();
    ptr2->myFunc();
    cout<<"test 1 done\n"<<endl;

    ptr2 = ptr1; // original allocated ptr2 will be destroied, by Tom Xue
    ptr2->myFunc();
    // ptr1->myFunc();//取消注释会发生段错误或未定义结果
    cout<<"test 2 done\n"<<endl;

    MyClass* ptr = ptr2.get();
    ptr->myFunc();
    ptr2.reset(new MyClass(3)); // so ptr/ptr1 is destroied 
    ptr2->myFunc();
    ptr->myFunc(); //此处会产生未定义的结果
    cout<<"test 3 done\n"<<endl;

    ptr4 = std::move(ptr3);  // now it's clear that ptr1 is no longer usable
    assert(!ptr3);

    return 0;   // then ptr2(3) will be destroied
}
Esempio n. 6
0
int main(int ac, char **av)
{
    Unit unit;
    MyClass myClass;
#if 0
    /*报错: method的参数不是普通变量,而是一个类的成员方法,不允许这样用*/
    //myClass.method(unit.process);
    
    /* 解决方法 1. 将process() 变成静态的方法(与全局函数一样,都是全局的*/
    myClass.method(unit.process);//此时可以调用
    
#endif
    /*
        产生新问题:如果么某个类不可见,它内部的方法又不是static全局的,就
                  无法调用了?
             解决:可以使用Lambda表达式解决,直接使用已经定义好的类
                  也可以使用函数对象,但是又要重新写这段代码,麻烦.
     */
    
    //注意:Lambda表达式对访问外部变量有限制,需要在[]里使用  &、= 符号
    myClass.method([&](int n){unit.process(n);});
    
    //注意:如果使用 = 号,最好将方法声明为const,因为如果编译器觉得你会修改
    //     里边的值,就要报错,编译器不是万能的,这个是否报错,不确定.
    myClass.method([=](int n){unit.process(n);});
    
    //这样也可以
    myClass.method([unit](int n)mutable{unit.process(n);});


    return 0;
}
Esempio n. 7
0
int main ()
{
    int a = 2;
    MyClass c (a);
    c.print();
    return 0;
}
Esempio n. 8
0
int main() {
	int a = 0;
/*	
	while(a < 3) {
		cout << "a";
		a++;
	}

	do {
		cout << "b" ;
	} while(++a < 6);
*/
	void *cmd[] = { &&____lbl____3 };
____lbl____3:
	cout << "haha";
	for(int i = 0; i < 10; ++i) {
		for(int j = 0; j < 2; j++){
			cout << i << "," << j << "\n";
			goto *cmd[0];
		}
		for(;; i++);
		for( ;i<0;) recursive(i);
		for(int k = 0; k < 3; ++k)
			cout << i << "," << k << "xx\n";
	}
	MyClass<int> c;
	c.out(10);

	return 0;
}
Esempio n. 9
0
int main(int argc, char *argv[])
{
	QApplication a(argc, argv);
	MyClass w;
	w.show();
	return a.exec();
}
MyClass::MyClass(const MyClass & rhs)
{
    itsAge = new int;
    itsWeight = new int;
    *itsAge = rhs.GetAge();
    *itsWeight = rhs.GetWeight();
}
Esempio n. 11
0
int main() {
    MyClass obj;

    obj.Run();

    return 0;
}
Esempio n. 12
0
int main(){
  MyClass::my_static_method();
  // -> I'm static method!

  MyClass x;
  x.my_instance_method();
  // -> I'm instance method!
}
Esempio n. 13
0
int main()
{
   foo(3, 4);
   MyClass c;
   c.doSmth(new baz());
      

}
int main(int argc, char** argv) {
    MyClass* pobj = new MyClass();

    pobj->setProperty("readOnly", true);
    bool bReadOnly = pobj->property("readOnly").toBool();

    return 0;
}
Esempio n. 15
0
int main()
{
    cout << "Math class:" << endl;
    MyClass mymath;
    cout << "10+20 = " << mymath.addition(10, 20) << endl;
    cout << "10*20 = " << mymath.multiplication(10,20) << endl;
    return 0;
}
Esempio n. 16
0
int main () {
    std::cout << a.getValue() << std::endl;
    std::cout << aa.getValue() << std::endl;
    std::cout << ab.getValue() << std::endl;
    std::cout << ac.getValue() << std::endl;

    
    return 0;
}
int main(void){
   MyClass one(1, 1, 1);
   MyClass defaults;
   MyClass happy(101, 101, 101);

   one.show_numbers();
   defaults.show_numbers();
   happy.show_numbers();
}
Esempio n. 18
0
int main() {
    MyClass mc;
    mc.fun();
    mc.fun(1);
    mc.fun(1,2);
    mc.fun(1,2,3);

    return 0;
}
int main()
{
	MyClass c;
	c = 5;  	// conversion constructor is called here  (see and check if it works for double or even string!!!)
	cout << c.getX() << endl;

	MyClass2 c2(10);
	return 0;
}
Esempio n. 20
0
int main()
{
	MyClass c;
	c.seta(10);
	int val = c.geta();	
	cout<<"Val is : "<<val;
	getchar();
	return 0;
}
Esempio n. 21
0
int main(void)
{
    MyClass* cc = new MyClass();
    const MyClass* ccc = cc;
    cc->Foo();
    ccc->Foo();
    delete cc;
    ccc = NULL;
    return 0;
}
Esempio n. 22
0
int main()
{
	MyClass foo (10);
	const MyClass bar (20);
	foo.get() = 16;
	cout << foo.get() << endl;
	cout << bar.get() << endl;

	return 0;
}
Esempio n. 23
0
int main(int ac, char **av)
{
    //MyClass result = 20 * MyClass(30);// = MyClass(30) * 20;
    //cout << result.mValue  << endl; 问题来了:私有成员,不让访问...

    MyClass result = 20 * MyClass(30);
    result.print();

    return 0;
}
Esempio n. 24
0
int main(int , char **)
{
    MyClass mc;

    std::string s = mc.appendString("Hello ", "World!");

    std::cout << s << std::endl;

    return 0;
}
Esempio n. 25
0
int main()
{
    const MyClass myConstClass = MyClass();
    myConstClass.getI();
    
    MyClass myNonConstClass;
    myNonConstClass.getI();
    
    return 0;
}
Esempio n. 26
0
int main(void) {

	string inputStr;

	getline(cin, inputStr);
	MyClass myClass;
	int strlength = inputStr.length();
	int * prefArray = myClass.Pref(inputStr, strlength);
	cout << strlength - prefArray[strlength - 1] << endl;
	return 0;
}
int main () 
{
  MyClass a;
  a.SetUpdateMethod(1);
  a.Update(3,4);

  a.SetUpdateMethod(2);
  a.Update(5,6);
  
  return 0;
}
Esempio n. 28
0
int main(int argc, char* argv[])
{
  MyClass<double> myClass;
  myClass.Output(2.0f);

  Simple<int> mySimple;
  MyClass<Simple<int> > myClass2;
  myClass2.Output(mySimple);

  return 0;
}
int main(int argc, char **argv)
{
     QApplication app(argc, argv);

     MyClass cl;
     cl.show();
     QObject::connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()));

     int ret = app.exec();
     return ret;
}
Esempio n. 30
0
int main ()
{
   MyClass myClass;

   std::thread tr (std::ref (myClass));
   tr.join ();

   std::cout << "Foo=" << myClass.getFoo () << " Goo=" << myClass.getGoo () << std::endl;
   
   return 0;
}