Results 1 to 3 of 3

Thread: [Sloved] Network without gui

  1. #1
    Join Date
    Feb 2008
    Posts
    21
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default [Sloved] Network without gui

    Hello,

    I have a problem to run my server application, because my application requires a x server. I will not compile with QtGui. Wich library i have included that requieres QtGui ?

    Compiler message:
    make
    make -f Makefile.Debug
    make[1]: Entering directory `/home/osadmin/workspace/qconfigcontrol-server'
    g++ -c -pipe -fpermissive -g -Wall -W -D_REENTRANT -DQT_SHARED -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtNetwork -I/usr/include/qt4/QtNetwork -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtGui -I/usr/include/qt4 -Idebug -I. -o debug/main.o src/main.cpp
    g++ -Wl,--no-undefined -o qconfigcontrol-server debug/server.o debug/main.o debug/moc_server.o -L/usr/lib -lQtGui -lQtNetwork -lQtCore -lpthread
    make[1]: Leaving directory `/home/osadmin/workspace/qconfigcontrol-server'

    server.h

    Qt Code:
    1. #ifndef SERVER_H_
    2. #define SERVER_H_
    3. #include <QTcpServer>
    4. #include <QByteArray>
    5. #include <QProcess>
    6.  
    7. class CServer : public QObject {
    8. Q_OBJECT
    9. public:
    10. CServer();
    11. ~CServer() {}
    12. private slots:
    13. void sendData( QByteArray data );
    14. private:
    15. typedef struct {
    16. QString filesystem;
    17. QString size;
    18. QString available;
    19. QString used;
    20. QString usedPercent;
    21. QString mountPoint;
    22. } SHardDrive;
    23.  
    24. QTcpServer *tcpServer;
    25. QProcess *process;
    26. QList<SHardDrive*> disk;
    27. void parseMountPoints();
    28. };
    29.  
    30. #endif /*SERVER_H_*/
    To copy to clipboard, switch view to plain text mode 

    server.cpp

    Qt Code:
    1. #include "server.h"
    2. #include <QFile>
    3.  
    4. CServer::CServer() {
    5. tcpServer = new QTcpServer(this);
    6. if (!tcpServer->listen()) {
    7. qWarning("ERROR: Unable to start server\n");
    8. return;
    9. }
    10.  
    11. qWarning("Status: OK\n");
    12.  
    13. }
    14.  
    15. void CServer::parseMountPoints() {
    16. QString cmd("df");
    17. process = new QProcess(this);
    18.  
    19. process->start(QFile::encodeName(cmd).data(), QStringList() << "-h");
    20.  
    21. if (!process->waitForFinished()) {
    22. qWarning("ERROR: could not read mount points\n");
    23. return;
    24. }
    25.  
    26. QString line = process->readAll();
    27.  
    28. if (line.isEmpty()) {
    29. qWarning("ERROR: no data found\n");
    30. return;
    31. }
    32.  
    33. QStringList partitionLine = line.split("\n", QString::SkipEmptyParts);
    34.  
    35. SHardDrive *hdd = NULL;
    36. QStringList partitionSplit;
    37.  
    38. for (int i=0; i<partitionLine.size(); i++) {
    39. QRegExp rx("/dev/*");
    40. rx.setPatternSyntax(QRegExp::Wildcard);
    41.  
    42. if (rx.exactMatch(partitionLine[i])) {
    43. partitionSplit = partitionLine[i].split(QRegExp("\\s+"), QString::SkipEmptyParts);
    44. hdd = new SHardDrive;
    45. disk.append(hdd);
    46. hdd->filesystem = partitionSplit[0];
    47.  
    48. if (partitionSplit.size() < 2) {
    49. partitionSplit = partitionLine[i+1].split(QRegExp("\\s+"), QString::SkipEmptyParts);
    50. hdd->size = partitionSplit[0];
    51. hdd->used = partitionSplit[1];
    52. hdd->available = partitionSplit[2];
    53. hdd->usedPercent = partitionSplit[3];
    54. hdd->mountPoint = partitionSplit[4];
    55. } else {
    56. hdd->size = partitionSplit[1];
    57. hdd->used = partitionSplit[2];
    58. hdd->available = partitionSplit[3];
    59. hdd->usedPercent = partitionSplit[4];
    60. hdd->mountPoint = partitionSplit[5];
    61. }
    62. }
    63. }
    64.  
    65. delete hdd;
    66. }
    67.  
    68. void CServer::sendData( QByteArray data ) {
    69. }
    To copy to clipboard, switch view to plain text mode 

    main.cpp

    Qt Code:
    1. #include <QtCore>
    2. #include <QCoreApplication>
    3. #include "server/server.h"
    4.  
    5. int main(int argc, char *argv[])
    6. {
    7. QCoreApplication app(argc, argv);
    8.  
    9. CServer server;
    10.  
    11. return app.exec();
    12. }
    To copy to clipboard, switch view to plain text mode 

    so long

    jd
    Last edited by jd; 29th February 2008 at 15:54.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Network without gui

    Add QT-=gui to your project file.

  3. #3
    Join Date
    Feb 2008
    Posts
    21
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Network without gui

    It works fine.

    Thanks

    jd

Similar Threads

  1. No network when Modem Emulator connect to a real device
    By tommy_tang in forum Qt for Embedded and Mobile
    Replies: 3
    Last Post: 10th December 2007, 08:24
  2. qmake ignores network?
    By Morea in forum Qt Programming
    Replies: 2
    Last Post: 24th June 2007, 09:29
  3. QByteArray with network data
    By merlvingian in forum Qt Programming
    Replies: 1
    Last Post: 1st June 2007, 17:53
  4. Beginning network programming
    By Morea in forum Qt Programming
    Replies: 3
    Last Post: 29th May 2007, 19:39
  5. QSocket - signal for network wire disconnection
    By manivannan_1984 in forum Qt Programming
    Replies: 7
    Last Post: 5th September 2006, 13:52

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.