Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Language Bindings
  4. QMessageBox executing action even thou I clicked NO
Forum Updated to NodeBB v4.3 + New Features

QMessageBox executing action even thou I clicked NO

Scheduled Pinned Locked Moved Language Bindings
1 Posts 1 Posters 1.5k 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.
  • I Offline
    I Offline
    ivica
    wrote on last edited by
    #1

    Hello my friends,

    yet again I have trouble with my code (which WORKED a few days ago...). In my project, I made a pushButton which is connected to a function which deletes a row from sqlite database. Function is displayed below.

    Problem is, a row will be deleted EVEN IF I PRESS NO. MessageBox pops up with the question, but whatever answer I chose, it ALWAYS executes the query.

    @def deleteFromDB(self):
    name = (str(self.ui.searchName.text()).upper())
    if name:
    with con:
    cur = con.cursor()
    cur.execute('SELECT name FROM cases WHERE name =?',[name])
    tempname = str(cur.fetchone())
    if len(tempname) != 4 :
    reply = QtGui.QMessageBox.question(self, 'Removal',
    "Are you sure ", QtGui.QMessageBox.Yes |
    QtGui.QMessageBox.No, QtGui.QMessageBox.No)
    if reply == QtGui.QMessageBox.Yes:
    cur.execute('DELETE FROM cases where name =?',[name])@

    indentation might be a little off, because my editor uses tabs for indentation and I tried to fix it on the spot for this posting.

    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