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. pop up menu from unit test
Forum Updated to NodeBB v4.3 + New Features

pop up menu from unit test

Scheduled Pinned Locked Moved Unsolved General and Desktop
qtestqmenu
3 Posts 2 Posters 1.0k Views
  • 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.
  • E Offline
    E Offline
    eleventy
    wrote on 17 Feb 2020, 20:50 last edited by eleventy
    #1

    I'm writing a test and need to verify the action around a popup (context) menu.

    I tried to do it via right-click, but I think I'm running into https://bugreports.qt.io/browse/QTBUG-52552

    I'm trying to work around that limitation by using the keyboard, but I don't see the menu pop up. I even added a qWarning() into the slot that pops up the menu, and I don't see that output when the test case runs. Note that I do see the qWarning() and the context menu when I perform these actions manually.

    QTest::keyClick(pd.ui->repTable, Qt::Key_Down);
    QTest::keyClick(pd.ui->repTable, Qt::Key_Right);
    QTest::keyClick(pd.ui->repTable, Qt::Key_Menu);
    QTest::qWait(1000);
    

    The widget is visible when the test is running, and I can see the effects of the down/right keys are behaving as expected. But there is no context menu.

    1 Reply Last reply
    0
    • C Offline
      C Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 18 Feb 2020, 05:43 last edited by
      #2

      Simply use QComboBox::showPopup() as it's done in tst_qcombobox: https://code.woboq.org/qt5/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp.html#932

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      E 1 Reply Last reply 18 Feb 2020, 12:59
      1
      • C Christian Ehrlicher
        18 Feb 2020, 05:43

        Simply use QComboBox::showPopup() as it's done in tst_qcombobox: https://code.woboq.org/qt5/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp.html#932

        E Offline
        E Offline
        eleventy
        wrote on 18 Feb 2020, 12:59 last edited by
        #3

        @Christian-Ehrlicher The widget that needs to show the context menu is a QTableView, not a QComboBox.

        1 Reply Last reply
        0

        3/3

        18 Feb 2020, 12:59

        • Login

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