frenk_castle
16th September 2009, 11:35
I have been studying the SDI/MDI example in my Qt4 and in my book Foundations of Qt development. I have two questions. I tried to provide enough details. If I wrote to much I apologize.
1.
In the Qt4 example there is a line of code
newAct->setShortcuts(QKeySequence::New);
The line with same functionality in the book is
newAction->setShortcut( tr("Ctrl+N") );
I have read the help provided with the Qt there is a whole table of values for enum QKeySequence::StandardKey. As far as I have managed to conclude the first version
QKeySequence::QKeySequence ( StandardKey key )
is platform dependent. It doesn't say, as far as I can see if second version
QKeySequence::QKeySequence ( const QString & key )
is platform dependent.
Is there any real difference between these to versions and if there are some what are they?
2.
There was a thread about this but it didn't clarify it for me at all.
If I have type class B for instance and I want to use it as a member in my type class A. Code that I would use would look something like this.
class_B.h
#ifndef CLASS_B_H
#define CLASS_B_H
class B
{
//some code
}
#endif
class_B.cpp
#include "class_B.h"
//some code
class_A.h
#ifndef CLASS_A_H
#define CLASS_A_H
#include "class_B.h"
class A
{
private:
B b;
//some code
}
#endif
In the example in Qt class MainWindow derived from QMainWindow has QAction class member among others. But instead of including the QAction header the code is
QT_BEGIN_NAMESPACE
class QAction;
class QMenu;
class QTextEdit;
QT_END_NAMESPACE
Will somebody explain to me what this code do exactly or where can I read it in details. I failed to find it in the Qt help. Why not just include all the headers? I know that namespace for instance can be a problem. When using for instance string from Standard template library even when you include the string header you need to write using std::string or to declare every string object with std:string sBuffer so that compiler can use the right type.
I would appreciate any help you can provide. Thanks in advance.
1.
In the Qt4 example there is a line of code
newAct->setShortcuts(QKeySequence::New);
The line with same functionality in the book is
newAction->setShortcut( tr("Ctrl+N") );
I have read the help provided with the Qt there is a whole table of values for enum QKeySequence::StandardKey. As far as I have managed to conclude the first version
QKeySequence::QKeySequence ( StandardKey key )
is platform dependent. It doesn't say, as far as I can see if second version
QKeySequence::QKeySequence ( const QString & key )
is platform dependent.
Is there any real difference between these to versions and if there are some what are they?
2.
There was a thread about this but it didn't clarify it for me at all.
If I have type class B for instance and I want to use it as a member in my type class A. Code that I would use would look something like this.
class_B.h
#ifndef CLASS_B_H
#define CLASS_B_H
class B
{
//some code
}
#endif
class_B.cpp
#include "class_B.h"
//some code
class_A.h
#ifndef CLASS_A_H
#define CLASS_A_H
#include "class_B.h"
class A
{
private:
B b;
//some code
}
#endif
In the example in Qt class MainWindow derived from QMainWindow has QAction class member among others. But instead of including the QAction header the code is
QT_BEGIN_NAMESPACE
class QAction;
class QMenu;
class QTextEdit;
QT_END_NAMESPACE
Will somebody explain to me what this code do exactly or where can I read it in details. I failed to find it in the Qt help. Why not just include all the headers? I know that namespace for instance can be a problem. When using for instance string from Standard template library even when you include the string header you need to write using std::string or to declare every string object with std:string sBuffer so that compiler can use the right type.
I would appreciate any help you can provide. Thanks in advance.