iqtgui.h
Go to the documentation of this file.
1 #ifndef iqtgui_included
2 #define iqtgui_included
3 
4 
5 // Qt includes
6 #include <QtCore/QFile>
7 #include <QtCore/QTextStream>
8 
9 #if QT_VERSION > 0x050000
10 #include <QtWidgets/QWidget>
11 #include <QtWidgets/QStyle>
12 #else
13 #include <QtGui/QWidget>
14 #include <QtGui/QStyle>
15 #endif
16 
17 // ACF includes
18 #include <iqt/iqt.h>
19 
20 
24 namespace iqtgui
25 {
26 
27 
31 template <class StyleSheetConsumer>
32 static bool SetStyleSheetFromFile(StyleSheetConsumer& styleSheetConsumer, const QString& styleSheetFilePath)
33 {
34  if (styleSheetFilePath.isEmpty()){
35  styleSheetConsumer.setStyleSheet("");
36 
37  return true;
38  }
39 
40  QFile styleSheetFile(styleSheetFilePath);
41  if (styleSheetFile.open(QIODevice::ReadOnly | QIODevice::Text)){
42  QTextStream stream(&styleSheetFile);
43  QString styleSheetText;
44  QString textLine;
45  do{
46  textLine = stream.readLine();
47  styleSheetText += textLine;
48  } while (!textLine.isNull());
49 
50  styleSheetConsumer.setStyleSheet(styleSheetText);
51 
52  return true;
53  }
54 
55  return false;
56 }
57 
58 
59 } // namespace iqtgui
60 
61 
62 #endif // !iqtgui_included
63 
64 
static bool SetStyleSheetFromFile(StyleSheetConsumer &styleSheetConsumer, const QString &styleSheetFilePath)
Set style sheet to any supported object.
Definition: iqtgui.h:32

© 2007-2017 Witold Gantzke and Kirill Lepskiy