Back to index

salome-gui  6.5.0
QtHelper.hxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 #ifndef _QT_HELPER_HXX_
00021 #define _QT_HELPER_HXX_
00022 
00023 //
00024 // =============================================================
00025 // Macro and template functions for type conversions.
00026 // =============================================================
00027 //
00028 #include "Basics_Utils.hxx" // To get ToString macro
00029 #include <QString>
00030 
00031 // This can be used to convert QString into char *.
00032 #define QCHARSTAR(qstring) qstring.toLatin1().data()
00033 // This converts a string into a QString
00034 #define S2QS(string) QString(string.c_str())
00035 // This converts a QString into a string
00036 #define QS2S(qstring) ToString(QCHARSTAR(qstring))
00037 #define QSTRING(any) S2QS(ToString(any))
00038 
00039 //
00040 // =============================================================
00041 // General helper macros for manipulating widgets values
00042 // =============================================================
00043 //
00044 #define GETTEXT(widget) ToString(QCHARSTAR(widget->text().trimmed()))
00045 #define SETTEXT(widget,str) widget->setText(str.c_str())
00046 
00047 //
00048 // =============================================================
00049 // Qt Logger macros
00050 // =============================================================
00051 //
00052 
00053 // We can use the macros defined by SALOMELocalTrace/utilities.h
00054 // as proposed in the file KERNEL_helper.hxx. But we can use instead
00055 // the Qt debug function:
00056 #include <QDebug>
00057 #define QDEBUG qWarning()
00058 //#define QDEBUG qDebug()
00059 #define QLOG(data) QDEBUG << "[XSALOME] " << data
00060 #ifdef LOG
00061 #undef LOG
00062 #endif
00063 #define LOG QLOG
00064 
00065 #endif // __QT_HELPER_H_