<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Battery status Problem]]></title><description><![CDATA[<p dir="auto">I am trying to make a gui that has a few buttons that will give information for a handheld device.  In this case a beagle board.  I started the project using Qt widget Project/QT gui application.</p>
<p dir="auto">One of the buttons has to show a "Battery Status Bar."  I am working on that and am getting some errors.  I could use some advice on how to resolve these.  I will post the error messages followed by my code.</p>
<p dir="auto">@In file included from ..\gui\main.cpp:2:<br />
..\gui/mainwindow.h:9: error: expected constructor, destructor, or type conversion before 'namespace'<br />
..\gui/mainwindow.h:25: error: 'Ui' has not been declared<br />
..\gui/mainwindow.h:25: error: ISO C++ forbids declaration of 'MainWindow' with no type<br />
..\gui/mainwindow.h:25: error: expected ';' before '*' token<br />
mingw32-make.exe[1]: *** [debug/main.o] Error 1<br />
mingw32-make.exe: *** [debug] Error 2<br />
00:51:37: The process "C:\QtSDK\mingw\bin\mingw32-make.exe" exited with code 2.<br />
Error while building project gui (target: Desktop)<br />
When executing build step 'Make'@</p>
<p dir="auto">Here is what I have for my code:</p>
<p dir="auto"><em><a href="http://gui.pro" target="_blank" rel="noopener noreferrer nofollow ugc">gui.pro</a>:</em></p>
<p dir="auto">@#-------------------------------------------------</p>
<h1></h1>
<h1>Project created by QtCreator 2012-04-25T01:13:25</h1>
<h1></h1>
<p dir="auto">#-------------------------------------------------</p>
<p dir="auto">QT       += core gui</p>
<p dir="auto">TARGET = gui<br />
TEMPLATE = app</p>
<p dir="auto">SOURCES += main.cpp<br />
mainwindow.cpp</p>
<p dir="auto">HEADERS  += mainwindow.h <br />
qmobilityglobal.h</p>
<p dir="auto">FORMS    += mainwindow.ui</p>
<p dir="auto">CONFIG += mobility<br />
MOBILITY += systeminfo<br />
@</p>
<p dir="auto"><em>mainwindow.h:</em></p>
<p dir="auto">@#ifndef MAINWINDOW_H<br />
#define MAINWINDOW_H</p>
<p dir="auto">#include &lt;QMainWindow&gt;<br />
#include &lt;QSysInfo&gt;</p>
<p dir="auto">//QTM_USE_NAMESPACE</p>
<p dir="auto">namespace Ui {<br />
class MainWindow;<br />
class ButtonClicked;<br />
}<br />
class MainWindow : public QMainWindow<br />
{<br />
Q_OBJECT</p>
<p dir="auto">public:<br />
explicit MainWindow(QWidget *parent = 0);<br />
~MainWindow();</p>
<p dir="auto">private slots:<br />
void ButtonClicked();</p>
<p dir="auto">private:<br />
Ui::MainWindow *ui;<br />
void setupGeneral();</p>
<pre><code>QSysInfo *deviceInfo;
</code></pre>
<p dir="auto">};</p>
<p dir="auto">#endif // MAINWINDOW_H@</p>
<p dir="auto"><em>main.cpp:</em></p>
<p dir="auto">@#include &lt;QtGui/QApplication&gt;<br />
#include "mainwindow.h"<br />
#include "qmobilityglobal.h"</p>
<p dir="auto">int main(int argc, char <em>argv[])<br />
{<br />
QApplication a(argc, argv);<br />
MainWindow w;<br />
w.show();<br />
/</em>   DigitalClock clock;<br />
clock.show();<br />
*/<br />
return a.exec();<br />
}@</p>
<p dir="auto"><em>mainwindow.cpp:</em></p>
<p dir="auto">@#include "mainwindow.h"<br />
#include "ui_mainwindow.h"<br />
#include "qmobilityglobal.h"<br />
#include &lt;QtGui&gt;</p>
<p dir="auto">MainWindow::MainWindow(QWidget *parent) :<br />
QMainWindow(parent),<br />
ui(new Ui::MainWindow)<br />
//deviceInfo(NULL)<br />
{<br />
ui-&gt;setupUi(this);<br />
setupGeneral();<br />
ui-&gt;batteryLevelBar-&gt;hide();<br />
}</p>
<p dir="auto">// Press Button to see Battery Status Bar<br />
void MainWindow::ButtonClicked() {<br />
if (ui-&gt;batteryLevelBar-&gt;isVisible())<br />
ui-&gt;batteryLevelBar-&gt;setVisible(false);<br />
else<br />
ui-&gt;batteryLevelBar-&gt;setVisible(true);<br />
}</p>
<p dir="auto">// Get Battery Info<br />
void MainWindow::setupGeneral()<br />
{<br />
deviceInfo = new QSysInfo(this);<br />
ui-&gt;batteryLevelBar-&gt;setValue(deviceInfo-&gt;batteryLevel());<br />
connect(deviceInfo, SIGNAL(batteryLevelChanged(int)),<br />
ui-&gt;batteryLevelBar, SLOT(setValue(int)));<br />
}</p>
<p dir="auto">MainWindow::~MainWindow()<br />
{<br />
delete ui;<br />
}@</p>
<p dir="auto">I do not know enough about C++ to figure this one out.  Appreciate the help.</p>
]]></description><link>https://forum.qt.io/topic/16211/battery-status-problem</link><generator>RSS for Node</generator><lastBuildDate>Tue, 22 Sep 2026 18:14:00 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/16211.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 26 Apr 2012 07:06:24 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Battery status Problem on Fri, 27 Apr 2012 06:38:27 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">your compile error showed up in the mainwindow.h file, so I removed all things that were not related to that :-)</p>
]]></description><link>https://forum.qt.io/post/137185</link><guid isPermaLink="true">https://forum.qt.io/post/137185</guid><dc:creator><![CDATA[giesbert]]></dc:creator><pubDate>Fri, 27 Apr 2012 06:38:27 GMT</pubDate></item><item><title><![CDATA[Reply to Battery status Problem on Thu, 26 Apr 2012 16:07:19 GMT]]></title><description><![CDATA[<p dir="auto">yes, but doesnt that basically get rid of what I want to do with the progress bar and battery status?  I think I should be using QSystemDeviceInfo instead of QSysInfo, but I cant seem to find that file.  When I add a QML file with the following:</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/import">@<bdi>import</bdi></a> QtMobility.systeminfo 1.2@</p>
<p dir="auto">But then I get the folowing error message:</p>
<p dir="auto">@In file included from ..\gui\main.cpp:2:<br />
..\gui/mainwindow.h:32: error: ISO C++ forbids declaration of 'QSystemDeviceInfo' with no type<br />
..\gui/mainwindow.h:32: error: expected ';' before '*' token<br />
mingw32-make.exe[1]: *** [debug/main.o] Error 1<br />
mingw32-make.exe: *** [debug] Error 2<br />
09:55:18: The process "C:\QtSDK\mingw\bin\mingw32-make.exe" exited with code 2.<br />
Error while building project gui (target: Desktop)<br />
When executing build step 'Make'@</p>
]]></description><link>https://forum.qt.io/post/137109</link><guid isPermaLink="true">https://forum.qt.io/post/137109</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Thu, 26 Apr 2012 16:07:19 GMT</pubDate></item><item><title><![CDATA[Reply to Battery status Problem on Thu, 26 Apr 2012 11:29:33 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">no, just the content of the method:</p>
<p dir="auto">@<br />
#include "mainwindow.h"<br />
#include "ui_mainwindow.h"<br />
// #include "qmobilityglobal.h"<br />
#include &lt;QtGui&gt;</p>
<p dir="auto">MainWindow::MainWindow(QWidget *parent) :<br />
QMainWindow(parent),<br />
ui(new Ui::MainWindow)<br />
//deviceInfo(NULL)<br />
{<br />
ui-&gt;setupUi(this);<br />
setupGeneral();<br />
// ui-&gt;batteryLevelBar-&gt;hide();<br />
}</p>
<p dir="auto">// Press Button to see Battery Status Bar<br />
void MainWindow::ButtonClicked() {<br />
//     if (ui-&gt;batteryLevelBar-&gt;isVisible())<br />
//         ui-&gt;batteryLevelBar-&gt;setVisible(false);<br />
//     else<br />
//         ui-&gt;batteryLevelBar-&gt;setVisible(true);<br />
}</p>
<p dir="auto">// Get Battery Info<br />
void MainWindow::setupGeneral()<br />
{<br />
//      deviceInfo = new QSysInfo(this);<br />
//      ui-&gt;batteryLevelBar-&gt;setValue(deviceInfo-&gt;batteryLevel());<br />
//      connect(deviceInfo, SIGNAL(batteryLevelChanged(int)),<br />
//      ui-&gt;batteryLevelBar, SLOT(setValue(int)));<br />
}</p>
<p dir="auto">MainWindow::~MainWindow()<br />
{<br />
delete ui;<br />
}<br />
@</p>
]]></description><link>https://forum.qt.io/post/137071</link><guid isPermaLink="true">https://forum.qt.io/post/137071</guid><dc:creator><![CDATA[giesbert]]></dc:creator><pubDate>Thu, 26 Apr 2012 11:29:33 GMT</pubDate></item><item><title><![CDATA[Reply to Battery status Problem on Thu, 26 Apr 2012 08:27:18 GMT]]></title><description><![CDATA[<p dir="auto">Did you mean 18-23?<br />
@// Press Button to see Battery Status Bar<br />
//void MainWindow::ButtonClicked() {<br />
//    if (ui-&gt;batteryLevelBar-&gt;isVisible())<br />
//        ui-&gt;batteryLevelBar-&gt;setVisible(false);<br />
//    else<br />
//        ui-&gt;batteryLevelBar-&gt;setVisible(true);<br />
//}@</p>
]]></description><link>https://forum.qt.io/post/137046</link><guid isPermaLink="true">https://forum.qt.io/post/137046</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Thu, 26 Apr 2012 08:27:18 GMT</pubDate></item><item><title><![CDATA[Reply to Battery status Problem on Thu, 26 Apr 2012 08:20:34 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">I commented out:</p>
<p dir="auto">mainwindow.h:</p>
<ul>
<li>nothing</li>
</ul>
<p dir="auto">mainwindow.cpp:</p>
<ul>
<li>lines: 3, 13, 18-21, 27-30</li>
</ul>
<p dir="auto">main.cpp:</p>
<ul>
<li>line 3</li>
</ul>
<p dir="auto">pro file:</p>
<ul>
<li>removed the qmobilityglobal.h file</li>
</ul>
]]></description><link>https://forum.qt.io/post/137045</link><guid isPermaLink="true">https://forum.qt.io/post/137045</guid><dc:creator><![CDATA[giesbert]]></dc:creator><pubDate>Thu, 26 Apr 2012 08:20:34 GMT</pubDate></item><item><title><![CDATA[Reply to Battery status Problem on Thu, 26 Apr 2012 08:16:01 GMT]]></title><description><![CDATA[<p dir="auto">Can you share what you commented out?  I commented out the #include qmobilityglobal.h lines and get these errors:</p>
<p dir="auto">@..\gui\mainwindow.cpp: In member function 'void MainWindow::setupGeneral()':<br />
..\gui\mainwindow.cpp:28: error: no matching function for call to 'QSysInfo::QSysInfo(MainWindow* const)'<br />
c:\QtSDK\Desktop\Qt\4.8.1\mingw\include/QtCore/qglobal.h:1526: note: candidates are: QSysInfo::QSysInfo()<br />
c:\QtSDK\Desktop\Qt\4.8.1\mingw\include/QtCore/qglobal.h:1526: note:                 QSysInfo::QSysInfo(const QSysInfo&amp;)<br />
..\gui\mainwindow.cpp:29: error: 'class QSysInfo' has no member named 'batteryLevel'<br />
..\gui\mainwindow.cpp:31: error: no matching function for call to 'MainWindow::connect(QSysInfo*&amp;, const char*, QProgressBar*&amp;, const char*)'<br />
c:\QtSDK\Desktop\Qt\4.8.1\mingw\include/QtCore/qobject.h:204: note: candidates are: static bool QObject::connect(const QObject*, const char*, const QObject*, const char*, Qt::ConnectionType)<br />
c:\QtSDK\Desktop\Qt\4.8.1\mingw\include/QtCore/qobject.h:217: note:                 static bool QObject::connect(const QObject*, const QMetaMethod&amp;, const QObject*, const QMetaMethod&amp;, Qt::ConnectionType)<br />
c:\QtSDK\Desktop\Qt\4.8.1\mingw\include/QtCore/qobject.h:337: note:                 bool QObject::connect(const QObject*, const char*, const char*, Qt::ConnectionType) const<br />
mingw32-make.exe[1]: Leaving directory `C:/Users/sabrina/Documents/Sabrina/QT Creator/Projects/senior project/gui-build-desktop-Qt_4_8_1_for_Desktop_-_MinGW__Qt_SDK__Debug'<br />
mingw32-make.exe[1]: *** [debug/mainwindow.o] Error 1<br />
mingw32-make.exe: *** [debug] Error 2<br />
02:12:54: The process "C:\QtSDK\mingw\bin\mingw32-make.exe" exited with code 2.<br />
Error while building project gui (target: Desktop)<br />
When executing build step 'Make'@</p>
]]></description><link>https://forum.qt.io/post/137043</link><guid isPermaLink="true">https://forum.qt.io/post/137043</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Thu, 26 Apr 2012 08:16:01 GMT</pubDate></item><item><title><![CDATA[Reply to Battery status Problem on Thu, 26 Apr 2012 08:02:52 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">I had to comment out some stuff, especially the mobility things and then i could compile it. so perhaps it's something inside qmobilityglobal.h ?</p>
<p dir="auto">I just tried it on windows with Qt 4.7.3</p>
]]></description><link>https://forum.qt.io/post/137041</link><guid isPermaLink="true">https://forum.qt.io/post/137041</guid><dc:creator><![CDATA[giesbert]]></dc:creator><pubDate>Thu, 26 Apr 2012 08:02:52 GMT</pubDate></item><item><title><![CDATA[Reply to Battery status Problem on Thu, 26 Apr 2012 07:45:07 GMT]]></title><description><![CDATA[<p dir="auto">oops..sorry, updated it.  Thanks for pointing that out.</p>
]]></description><link>https://forum.qt.io/post/137036</link><guid isPermaLink="true">https://forum.qt.io/post/137036</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Thu, 26 Apr 2012 07:45:07 GMT</pubDate></item><item><title><![CDATA[Reply to Battery status Problem on Thu, 26 Apr 2012 07:39:59 GMT]]></title><description><![CDATA[<p dir="auto">If you put the mainwindow.h code in instead the project files one, it woul be helpful :-)</p>
]]></description><link>https://forum.qt.io/post/137035</link><guid isPermaLink="true">https://forum.qt.io/post/137035</guid><dc:creator><![CDATA[giesbert]]></dc:creator><pubDate>Thu, 26 Apr 2012 07:39:59 GMT</pubDate></item></channel></rss>