Jump to content

Check out our Community Blogs


Member Since 09 Apr 2011
Offline Last Active Apr 25 2013 02:09 AM

#640160 [SOLVED][Qt]Project help - displaying doc file.

Posted by notes on 28 September 2012 - 01:49 PM

I never doubted in Qt's power but after achieving my goal with mere 4 lines of code(Working fonts, pictures, ect ect) I'm pretty amazed!
Solution was using ActiveX ( int Qt named ActiveQt Framework) and is posted below ;-)
    QAxWidget* WordDocument=new QAxWidget ("Word.Document", this-> ui-> textEdit);
    WordDocument-> setGeometry (QRect (10, 10, 621, 471));
    WordDocument->setControl ("D:\\Qt\\ProjektInzOp\\AlaMaKota.doc");
    WordDocument-> show ();

Put this with proper includes in your constructor, make some textEdit or anything else that can show text and see results :)
  • 1

#639674 How to make it work?

Posted by notes on 24 September 2012 - 07:13 AM

Do you want to save your current data so that another user can later run your program and see saved data ?
Or you want just to put your data in dynamic memory and see it while program is still running ?

The solution to first answer is - in my opinion- a bit more complex. You will have to store your time-date variable in some file on your disk.
To achive second question you will need to store data's in some sort of array, or list, vector, queue(all implemented in STL's).

In your place I would first try to open and read/write file on your disk and later try more complex tasks :)
  • 1

#638400 Just for laugh

Posted by notes on 11 September 2012 - 04:10 AM

Did you see Kung fu bear ? :)
  • 1

#638178 Operator overloading C++

Posted by notes on 09 September 2012 - 10:43 AM

Initialization list is a thing that is done in first order by the compiler... That's the only difference. So when you write
Complex (double re, double im ) : real(re) {
	imagine = im;

You are 100% sure that when line : imagine = im; will be in progress your real variable will be inicialized.
Initialization list is a kind of stack, if you will have more operations there first operation after ')' bracket will be done and then next one etc..

I have never used default parameter in constructor cause its confusing... But its matter of style. Certainly It's not proper to make all arguments default... anyways If you want use default parameter rather than two constructors Both of this work fine :
Complex(double r=0, double i=0) :real(r), imagine(i) {}

Complex(double r=0, double i=0) { real = r; imagine = i;}

One more thing, the first name on initialization list is one that you have as class member (private, public or protected ). Its the same as when you write later in main function ...
Complex c1(1,2);
You are calling for constructor on your initialization list ;-)

Hope this helps.
  • 2

#634081 A More Efficient Search

Posted by notes on 17 July 2012 - 07:00 AM

In programming string matching algorithms are very important. Once my teacher said that good programist should have knowledge of 3 disciplines :
1. Very good knowledge of language syntax.
2. Knowledge of object oriented programming (desing patterns )
3. And knowledge of algorithmics.
As i have seen you are using string declared methods for finding desired string. I couldn't find Big O notations of algorithm used there. But I encourage to read about string matching algorithms, that could speed up searching.
  • 1

#634069 Transferring Data From String Array

Posted by notes on 17 July 2012 - 04:20 AM

It's nice to write own function which is really simple.I wote my function which was changing string like 22-3+(31*3) to two stacks one integer type with values second char type with operators. In your case it would be much simplier cause you have to read from '-' till next digit is not integer.
function that checks would look really simple like :

if (((int)num[0] > 47) && ((int)num[0] <58) )
return true;
return false;

You are comparing ASCII digits. Then you can append character to a temporary string where you'll have only numbers.
This is working prototype, I leave to you recognizing whenever its negative or positive int.
bool is_number(char c);
int str_to_int(string str);
int _tmain(int argc, _TCHAR* argv[])
string str ="-96dBm";
int result = str_to_int(str);
cout << "String: " << str<< "\nInt: " << result<< endl;
return 0;
bool is_number(char c) {
if ( ((int)c > 47) && ((int)c <58) )
return true;
return false;
int str_to_int(string str) {
int myResult = 0; // IMPORTANT to initialize this int.
string temp;
int j = 1;
// Want to start from 1 cause first char is '-'
	 // You may want to change is_number function to omit this.
while (is_number(str[j]) ) {
temp += str[j];
// Now we have number in temp;
int tempSize=temp.length()-1;
for (int i = 0; i <tempSize; i++ ) {
myResult*=10; // if 0 still 0
return myResult;

Edit : This is ms vc++ so to get this working youll need to include in stdafx.h:
#pragma once
#include "targetver.h"
#include <stdio.h>
#include <tchar.h>
#include <iostream>
#include <string>
using namespace std;

Or just make propper includes in your IDE ;-)

Hope this was helpful,
  • 1

#627931 Test Coming Up

Posted by notes on 24 April 2012 - 01:07 AM

There are few errors I cant understand in exercises.
1. You have to write function that returns boolean value ( true or false )and then it says that function will have to return some integer .... ?
2. I cant understand this task at all.. :/

As for your code. I suggest you try to put it in a function. Making class out of this few lines of code is pointless for me cause your class shall have string, int variable and one method...
Here is how I made function out of your code..
// main.cpp : Defines the entry point for the console application.
#include "stdafx.h"
#include <string>
#include <iostream>
using namespace std;
int ascii_sum(char char_arr[]);
int _tmain(int argc, _TCHAR* argv[])
char my_arr[100];
cin >> my_arr;
cout << endl << ascii_sum(my_arr) << endl;

return 0;
int ascii_sum(char char_arr[]) {
int size = strlen(char_arr);
int sum = 0;
for ( int i = 0 ; i < size ; i++) {
  cout << (int)char_arr[i] << " ";
cout << endl << "Sum :";
return sum;

Hope this helps.
  • 1

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download