|
Hi All.
Can any help me!
I am a MFC developer, my mission is porting from MFC to QT application. But I can not find the easy way to porting, it's so hard and maybe i lose my mission.
Can any know how to porting from MFC to QT. Please help me.
Thanks so much!
|
|
|
|
|
|
I have not done this but have written MFC and Qt applications.
Knowing both I would deny such a request because they are too different and porting is similar to rewriting the application. However, it all depends on the size of the existing application.
|
|
|
|
|
As others have eluded, I don't think there is an "easy way" to port the code over. You'll have to basically start re-writing things and solve problems as they come up. Having written things in both MFC and Qt, you may end up doing a lot of re-design since the frameworks can vary quite a bit with some things.
If you're looking for something that may be easier to port so that it works in other platforms (i.e.Linux), WxWidgets may be an easier port.
|
|
|
|
|
Hi ALL,
I am trying to get the timing exactly 2 days diff from current time.please advice i am not getting it correctly.
here is my code (-2 does not work)
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
int main() {
time_t current_time;
char* c_time_string;
current_time = time(NULL);
current_time = current_time -2
/* Convert to local time format. */
c_time_string = ctime(¤t_time);
printf("Current time is %s", c_time_string);
return 0;
}
|
|
|
|
|
http://en.cppreference.com/w/c/chrono/time[^]
Read the notes carefully.
If you have an important point to make, don't try to be subtle or clever. Use a pile driver. Hit the point once. Then come back and hit it again. Then hit it a third time - a tremendous whack.
--Winston Churchill
|
|
|
|
|
|
Oops! Try 60 * 60 * 24 * 2.
btw, seconds in a day is "eight six four two zeros" ie 86 400.
Cheers,
Peter
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
Ooops. Lack of coffee.
Thank you for the correction.
|
|
|
|
|
The time function returns seconds since Epoch. In order to obtain two days back you have to subtract the correct amount of seconds, e.g.
#include <stdio.h>
#include <time.h>
#define SECONDS_PER_DAY 86400
int main()
{
time_t current_time;
char* c_time_string;
current_time = time(NULL);
current_time = current_time - 2 * SECONDS_PER_DAY;
c_time_string = ctime(¤t_time);
printf("Current time is %s\n", c_time_string);
return 0;
}
|
|
|
|
|
The C-2011 standard does not specify the epoch or the resolution of time(). The POSIX standard specifies the epoch as 1970-01-01 00:00:00, and the resolution as seconds.
The fact that most runtime libraries follow the POSIX standard should not blind you to the fact that using this function to perform date arithmetic is inherently non-portable.
If you wish to perform date/time manipulations, you should use the functions that operate on the 'tm' structure.
If you have an important point to make, don't try to be subtle or clever. Use a pile driver. Hit the point once. Then come back and hit it again. Then hit it a third time - a tremendous whack.
--Winston Churchill
|
|
|
|
|
hello everyone, i made a tic tac toe in C language, using the minimax algorithm but i have some problem when i try to play with larger matrix more than 3x3 for example 4x4 and my program go out of memory.
So i search in the net and i discover the aplpha-beta pruning that reduce the computional coast and so i can play with 4x4 matrix whiteout problems but i have not idea to implement this algorithm to my minimax.
if there is a person who want to help me i would be grateful.
sorry for my bad english but i am italian
i can post my code if you want
|
|
|
|
|
You could start (if you haven't already done) with the Wikipedia's article on the subject: Alpha–beta pruning[^].
|
|
|
|
|
 hi, i read the article on wikipedia and i understand it but the problem is that i don't know how to implement it to my minimax
here is my minimax if want to give me an idea ..
int miniMax(char wnr, int deep){
if (controlloVincita(2)) return INT_MAX;
if (endgame())
return INT_MIN;
int i, j, res, tmp;
if (wnr == 1) {
res = 1;
for (i = 0;i<M;i++)
for (j = 0;j<N;j++)
{
if (BOARD[i][j]==0)
{
BOARD[i][j] = 1;
if (controlloVincita(1))
if (deep == 20)
{
BOARD[i][j] = 0;
return INT_MIN;
}
else
res -= 2;
else if ((tmp = miniMax(2, deep - 1))<res || (tmp == INT_MIN))
res = tmp;
BOARD[i][j] = 0;
}
}
}
else
{
res = -1;
for (i = 0;i<M;i++)
for (j = 0;j<N;j++)
{
if (BOARD[i][j]==0)
{
BOARD[i][j] = 2;
if (controlloVincita(2))
res += 2;
else if ((tmp = miniMax(1, deep - 1))>res || (tmp == INT_MAX))
res = tmp;
BOARD[i][j] = 0;
}
}
}
return res;
}
int get_next_move(unsigned int *i, unsigned int *j)
{
int max = INT_MIN, mi = 1, mj = 1, t;
int alfa = INT_MIN, beta = INT_MAX;
for (*i = 0;*i<M;(*i)++)
for (*j = 0;*j<N;(*j)++)
if (BOARD[*i][*j]==0) {
BOARD[*i][*j] = 2; t = miniMax(1, 20); if (t>max) {
max = t;
mi = *i;
mj = *j;
}
BOARD[*i][*j] = 0;
}
BOARD[mi][mj] = 2; *i = mi;
*j = mj;
return 1;
}
|
|
|
|
|
Hi all,
I need to define a structure (its some spec frame-structure), so that I can assign data and retrieve-fields easily.
So my definition is like below
struct MyDef
{
DWORD B1 : 8;
DWORD B2 : 8;
DWORD B3 : 8;
DWORD B4 : 8;
};
(Note that, the whole struct contains 32 bits.)
Now, I need a way to set some DWORD value to it directly. something like this
MyDef Def;
Def.data = 0xAABBCCDD;
(please note that, I need to keep the bit-fields so that I can set the fields as well.)
Please help me.
|
|
|
|
|
Without actually trying this out.... you should be able to take the pointer to the first element and load it with whatever data you want. Assuming your data matches the size of the structure, there should be no issue, be ware of data packing/memory alignment though.
Read this before you get yourself into trouble.[^]
|
|
|
|
|
You can do it by using a union[^] thus:
union MyDef
{
DWORD W1;
struct bits
{
DWORD B1 : 8;
DWORD B2 : 8;
DWORD B3 : 8;
DWORD B4 : 8;
};
};
which maps W1 to the same memory space as the four byte fields. You can now refer to the whole DWORD as W1 of the union structure.
|
|
|
|
|
how to parse html code in c language.
|
|
|
|
|
|
What books would you recommend for data structures and algorithms in C language?
It would be good if recommended books are books of solved problems.
|
|
|
|
|
|
This is a classic:
Algorithms in C[^]
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
I believe this is a later edition of the book I initially learned C with.... if that is the case, it's a pretty good book that emphasizes proper algorithms, which is great.
|
|
|
|
|
There is a windows message to know when windows scheme has changed from Windows 7 to Windows classic ? If yes, which is ? I have tried ON_WM_SETTINGCHANGE , but this one has fired several times, not just once ...
modified 5-Oct-15 8:56am.
|
|
|
|
|
I dig into ON_WM_SETTINGCHANGE message, but I didn't found something that tell me when the color scheme has changed ... I am thinking that this message is not the one of what I am looking for ...
|
|
|
|