当前位置: 首页>>代码示例>>C++>>正文


C++ MainWindow::AddItem方法代码示例

本文整理汇总了C++中MainWindow::AddItem方法的典型用法代码示例。如果您正苦于以下问题:C++ MainWindow::AddItem方法的具体用法?C++ MainWindow::AddItem怎么用?C++ MainWindow::AddItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MainWindow的用法示例。


在下文中一共展示了MainWindow::AddItem方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char *argv[])
{
  QApplication a(argc, argv);
  QRect screenGeometry = QApplication::desktop()->screenGeometry();
  int ret = -1;
  char *buf;
  int window_x, window_y; // posX, posY
  int window_w, window_h; // width, height
  const char *window_font; // font family
  int window_fs, window_fw; // font size, weight
  int window_is; // icon size
  bool fs;

  // Processing command line arguments
  buf = getCmd(argv, argv + argc, "--help");
  if (buf)
  {
    cout << "Application selector usage:\n"
            "    app-selector [OPTION]... < [ITEM FILE]\n"
            "\nwhere options include:\n"
            "    --fullscreen                 use the entire screen.\n"
            "    --geometry WxH               size of window.\n"
            "    --font fontname              font family name.\n"
            "    --font-size size             font point size.\n"
            "    --font-weight weight         font weight.\n"
            "    --icon-size size             icon size.\n"
            "\nStructure of JSON file :\n"
            "[\n  {\n"
            "    \"name\": <string>, /* Friendly name of application       */\n"
            "    \"exec\": <string>, /* Command line or any data as output */\n"
            "    \"icon\": <string>  /* Icon path                          */\n"
            "  }, ...\n"
            "]\n";
    return 0;
  }
  buf = getCmdOption(argv, argv + argc, "--fullscreen");
  if (buf)
    fs = true;
  else
    fs = false;
  buf = getCmdOption(argv, argv + argc, "--geometry");
  if (!buf || sscanf(buf, "%ix%i", &window_w, &window_h) != 2)
  {
    window_x = 0;
    window_y = 0;
    window_w = screenGeometry.width();
    window_h = screenGeometry.height();
  }
  else
  {
      window_x = (screenGeometry.width() - window_w) / 2;
      window_y = (screenGeometry.height() - window_h) / 2;
  }
  buf = getCmdOption(argv, argv + argc, "--font");
  if (!buf)
    window_font = WINDOW_DFLT_FONT_FAMILY;
  else
    window_font = buf;
  buf = getCmdOption(argv, argv + argc, "--font-size");
  if (!buf || sscanf(buf, "%i", &window_fs) != 1)
  {
    window_fs = WINDOW_DFLT_FONT_POINT_SIZE;
  }
  buf = getCmdOption(argv, argv + argc, "--font-weight");
  if (!buf || sscanf(buf, "%i", &window_fw) != 1)
  {
    window_fw = WINDOW_DFLT_FONT_WEIGHT;
  }
  buf = getCmdOption(argv, argv + argc, "--icon-size");
  if (!buf || sscanf(buf, "%i", &window_is) != 1)
  {
    window_is = WINDOW_DFLT_ICON_SIZE;
  }

  vitem v;
  readJsonFromStream(&cin, v);

  MainWindow window;

  // Setup our window size and position
  window.resize(window_w, window_h);
  window.move(window_x, window_y);

  // Setup our font face, size and weight
  QFont font;
  font.setFamily(QString::fromUtf8(window_font));
  font.setPointSize(window_fs);
  font.setBold(false);
  font.setWeight(window_fw);
  window.setFont(font);

  // Setup our icon size
  window.setIconSize(QSize(window_is, window_is));

  for (vitem::iterator it = v.begin(); it != v.end(); ++it)
    window.AddItem(*it);

  if (fs)
    window.showFullScreen();
  else
//.........这里部分代码省略.........
开发者ID:janbar,项目名称:app-selector,代码行数:101,代码来源:main.cpp


注:本文中的MainWindow::AddItem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。