开发者

how to use QtSingleApplication bt the so file?

开发者 https://www.devze.com 2023-01-28 08:26 出处:网络
I need to use QtSingleApplication in my Qt application. I didn\'t understand from the开发者_如何学JAVA documentation how to use the add on by the so file.

I need to use QtSingleApplication in my Qt application. I didn't understand from the开发者_如何学JAVA documentation how to use the add on by the so file. can you please help me? (step by step)

thanks!


It is pretty straightforward, put the following in main.cpp:

#include <QtSingleApplication>
#include <QWidget>


int main(int argc, char **argv)
{
  QtSingleApplication app(argc, argv);

  // if application is running, we terminate it
  if (app.isRunning())
    return 0;

  // application wasn't running, so we go on with our lives
  QWidget w;
  app.setActivationWindow(&w);
  w.show();

  return app.exec();
}

and in project's .pro file:

INCLUDE += -I/usr/local/include
LIBS += -L/usr/local/lib -lQtSingleApplication

and then perform the usual drill:

qmake
make
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号