Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Simulation click() for QMessageBox::question don't work properly
Forum Updated to NodeBB v4.3 + New Features

Simulation click() for QMessageBox::question don't work properly

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.4k 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.
  • Y Offline
    Y Offline
    yura-vel
    wrote on last edited by
    #1

    I have a wrapper for QMessageBox::question

    @bool Ask( const QString& text )
    {
    QMessageBox::StandardButton res;

    res = QMessageBox::question(    
        nullptr,
        QObject::tr( "Confirm Action" ),
        text,
        QMessageBox::Yes | QMessageBox::No); 
    

    return res == QMessageBox::Yes;
    }@

    And code that simulates pushing Ok button in the test

    @QList<QPushButton*> allPButtons = dialog->findChildren<QPushButton*>();
    for( auto it : allPButtons )
    {
    if( dialog->buttonRole( it ) == QMessageBox::YesRole )
    {
    it->click();
    break;
    }
    }@

    It closes the dialog, BUT the result (res variable) is QMessageBox::No.
    So the Ask function returns false.

    What need to fix to get QMessageBox::Yes in the result of QMessageBox::question;

    PS: when user clicks the Ok button by mouse - all works properly.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mcosta
      wrote on last edited by
      #2

      Hi,

      to understand what's going wrong print with qDebub() the text of clicked button

      Once your problem is solved don't forget to:

      • Mark the thread as SOLVED using the Topic Tool menu
      • Vote up the answer(s) that helped you to solve the issue

      You can embed images using (http://imgur.com/) or (http://postimage.org/)

      1 Reply Last reply
      0
      • Y Offline
        Y Offline
        yura-vel
        wrote on last edited by
        #3

        Sorry for every one, I found the problem. It in my code for processing dialogs in the tests. After some corrections all works properly.

        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