Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. International
  3. Chinese
  4. Main函数里面QMessageBox的exec返回0
Forum Updated to NodeBB v4.3 + New Features

Main函数里面QMessageBox的exec返回0

Scheduled Pinned Locked Moved Chinese
2 Posts 2 Posters 2.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Aaron_Cai
    wrote on last edited by
    #1

    @int main(int argc, char *argv[])
    {
    CustomApplication a(argc, argv);
    AppTest w;

    QMessageBox box;

    box.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
    box.setDefaultButton(QMessageBox::No);

    int ret = box.exec();

    if ( ret == QMessageBox::Yes )
    {
    qDebug() << "Yes clicked";
    }
    else if(ret == QMessageBox::No)
    {
    qDebug() << "No clicked";
    }
    else
    {
    qDebug() << ret << endl;
    }

    a.setActiveWindow(&w);
    return a.exec();
    }
    @
    在main函数弹出一个对话框,发现还没有点按钮,已经返回0了,如何解决?

    1 Reply Last reply
    0
    • J Offline
      J Offline
      jiangcaiyang
      wrote on last edited by
      #2

      不能这么写呢。因为QApplication都没有机会运行,主循环没有启动。

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved