g4tools  5.4.0
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
tools::Qt::session Class Reference

Public Member Functions

 session (std::ostream &a_out, int &a_argc, char **a_argv)
 
virtual ~session ()
 
std::ostream & out () const
 
bool is_valid () const
 
bool steer ()
 
bool sync ()
 
QApplication * qapp () const
 
QWidget * create_window (const char *a_title, int a_x, int a_y, unsigned int a_width, unsigned int a_height)
 
void delete_window (QWidget *a_window) const
 

Protected Member Functions

 session (const session &a_from)
 
sessionoperator= (const session &a_from)
 
QString s2q (const std::string &a_s)
 

Protected Attributes

std::ostream & m_out
 
QApplication * m_qapp
 
bool m_own_qapp
 

Detailed Description

Definition at line 26 of file session.

Constructor & Destructor Documentation

◆ session() [1/2]

tools::Qt::session::session ( std::ostream &  a_out,
int &  a_argc,
char **  a_argv 
)
inline

Definition at line 28 of file session.

29  :m_out(a_out)
30  ,m_qapp(0)
31  ,m_own_qapp(false)
32  {
33  if(qApp) {
34  m_qapp = qApp;
35  m_own_qapp = false;
36  } else {
37  m_qapp = new QApplication(a_argc,a_argv);
38  m_own_qapp = true;
39  }
40  }

◆ ~session()

virtual tools::Qt::session::~session ( )
inlinevirtual

Definition at line 41 of file session.

41  {
42  if(m_own_qapp && m_qapp) delete m_qapp;
43  m_qapp = 0;
44  m_own_qapp = false;
45  }

◆ session() [2/2]

tools::Qt::session::session ( const session a_from)
inlineprotected

Definition at line 47 of file session.

48  :m_out(a_from.m_out)
49  ,m_qapp(0)
50  ,m_own_qapp(false)
51  {}

Member Function Documentation

◆ create_window()

QWidget* tools::Qt::session::create_window ( const char *  a_title,
int  a_x,
int  a_y,
unsigned int  a_width,
unsigned int  a_height 
)
inline

Definition at line 71 of file session.

71  {
72  if(!m_qapp) return 0;
73 #ifdef _MSC_VER
74  if(a_y<=0) a_y = 60;
75 #endif
76  QWidget* top = new QWidget();
77  top->setWindowFlags(::Qt::CustomizeWindowHint
78  | ::Qt::WindowTitleHint
79  | ::Qt::WindowMinMaxButtonsHint
80 // | ::Qt::WindowSystemMenuHint
81 // | ::Qt::WindowFullscreenButtonHint
82  );
83  top->setGeometry(a_x,a_y,a_width,a_height);
84  top->setWindowTitle(s2q(a_title));
85  //top->setAttribute(Qt::WA_DeleteOnClose,false);
86  return top;
87  }

◆ delete_window()

void tools::Qt::session::delete_window ( QWidget *  a_window) const
inline

Definition at line 88 of file session.

88  {
89  if(!m_qapp) return;
90  delete a_window;
91  }

◆ is_valid()

bool tools::Qt::session::is_valid ( ) const
inline

Definition at line 58 of file session.

58 {return m_qapp?true:false;}

◆ operator=()

session& tools::Qt::session::operator= ( const session a_from)
inlineprotected

Definition at line 52 of file session.

52  {
53  if(&a_from==this) return *this;
54  return *this;
55  }

◆ out()

std::ostream& tools::Qt::session::out ( ) const
inline

Definition at line 57 of file session.

57 {return m_out;}

◆ qapp()

QApplication* tools::Qt::session::qapp ( ) const
inline

Definition at line 70 of file session.

70 {return m_qapp;}

◆ s2q()

QString tools::Qt::session::s2q ( const std::string &  a_s)
inlineprotected

Definition at line 93 of file session.

93  {
94 #if QT_VERSION < 0x050000
95  return QString::fromAscii(a_s.c_str());
96 #else
97  return QString::fromLatin1(a_s.c_str());
98 #endif
99  }

◆ steer()

bool tools::Qt::session::steer ( )
inline

Definition at line 59 of file session.

59  {
60  if(!m_qapp) return false;
61  m_qapp->exec();
62  return true;
63  }

◆ sync()

bool tools::Qt::session::sync ( )
inline

Definition at line 64 of file session.

64  {
65  if(!m_qapp) return false;
66  //m_qapp->exec();
67  return true;
68  }

Member Data Documentation

◆ m_out

std::ostream& tools::Qt::session::m_out
protected

Definition at line 101 of file session.

◆ m_own_qapp

bool tools::Qt::session::m_own_qapp
protected

Definition at line 103 of file session.

◆ m_qapp

QApplication* tools::Qt::session::m_qapp
protected

Definition at line 102 of file session.


The documentation for this class was generated from the following file:
tools::Qt::session::m_qapp
QApplication * m_qapp
Definition: session:102
tools::Qt::session::m_out
std::ostream & m_out
Definition: session:101
tools::sg::top
@ top
Definition: enums:82
tools::Qt::session::m_own_qapp
bool m_own_qapp
Definition: session:103
tools::Qt::session::s2q
QString s2q(const std::string &a_s)
Definition: session:93