Error when running NetAnim: QPixmap: Must construct a QApplication before a QPaintDevice

228 views
Skip to first unread message

Samuel Bwemere

unread,
May 26, 2023, 2:23:24 AM5/26/23
to ns-3-users
Hi everyone,

I have a simulation built with NS3-3.22 and that requires Netanim 3.105
I'm encountering an error while running the NetAnim application and I'm seeking some assistance in resolving it. The error message I'm receiving is :
 "QPixmap: Must construct a QApplication before a QPaintDevice."

```
//main.cpp
#include "netanim.h"

using namespace ns3;
using namespace netanim;

int main (int argc, char *argv[])
{
  ns3::LogComponentEnable ("AnimatorScene", ns3::LOG_LEVEL_ALL);
  ns3::LogComponentEnable ("AnimatorView", ns3::LOG_LEVEL_ALL);
  // Other ns-3 logging components

  QApplication app (argc, argv);
  app.setApplicationName ("NetAnim");
  app.setWindowIcon (QIcon (":/resources/netanim-logo.png"));

  NetAnim netAnim;
  return app.exec ();
}
```
```
//netanim.h
#ifndef NETANIM_H
#define NETANIM_H

#include "common.h"
#include "mode.h"

namespace netanim
{

class NetAnim : public QObject
{
  Q_OBJECT
public:
  NetAnim ();
  QTabWidget * getTabWidget();
private:
  typedef std::map <int, Mode *> TabIndexModeMap_t;
  QTabWidget * m_tabWidget;
  TabIndexModeMap_t m_TabMode;

private slots:
  void currentTabChangedSlot (int currentIndex);

};
}
#endif // NETANIM_H
```
I would greatly appreciate any guidance or suggestions on how to resolve this error. Please let me know if you need any additional information.

Thank you in advance for your help!

Best regards,
Samuel

Tommaso Pecorella

unread,
May 26, 2023, 4:01:52 PM5/26/23
to ns-3-users
Hi Samuel,

bad news: it might be a near-impossible-to-fix conflict with NetAnim 3.105 and the QT libraries that you have installed in your computer.

Good news: there are two workarounds.
  1. The painful one: remove QT and install the QT libraries that were used when 3.105 was issued.
  2. The less painful one: use a newer NetAnim.
The very good news is: the .XML format used by NetAnim doesn't really change much, so the newer versions should be able to read the "old" traces. I say "should" because I can't guarantee it - but I'm quite confident that it will work.

Samuel Bwemere

unread,
May 30, 2023, 1:56:09 AM5/30/23
to ns-3-users
Hi Tommaso, 

Thanks a lot for your help. I installed NetANim 3.105 & NS-3.22 on Ubuntu 18.04, using Qt4 et g++-4.28, it works.
Reply all
Reply to author
Forward
0 new messages