Results 1 to 2 of 2

Thread: More SQLite Woes and onFocus Woes

  1. #1

    Default More SQLite Woes and onFocus Woes

    AS if the problem i had yesterday is not enough i have another problem this time its just selecting a simple record from the database. i have this code:

    Qt Code:
    1. class loginPageView(QWidget, ui_loginui.Ui_Mainlogin):
    2.  
    3. def __init__(self, parent=None):
    4. super(loginPageView, self).__init__(parent)
    5. self.setupUi(self)
    6. self.lineEditer_login.setFocus()
    7. self.connect(self.lineEditer_login, SIGNAL("returnPressed()"), self.sqlEnterlogin)
    8.  
    9.  
    10. def sqlEnterlogin(self):
    11. texer = self.lineEditer_login.text()
    12. query = QSqlQuery()
    13. query.exec_("SELECT staff_id FROM staff WHERE password = pass1") ### %s" % (texer))
    14. if query.next():
    15. self.lineEditer_login.clear()
    16. texer2 = unicode(query.value(STAFF_ID).toString())
    17. self.lineEditer_login.setText("hello are you working? %s" % (texer2))
    18. ##self.emit(SIGNAL("loginSuccessful"))
    19. else:
    20. texer3 = QSqlQuery().lastError().text()
    21. self.lineEditer_login.setText("why are you not working? %s" % (texer3))
    22. QApplication.processEvents()
    To copy to clipboard, switch view to plain text mode 

    first is the self.lineEditer_login.setFocus() which is conflicting with a QGraphicsView Box on the ui_loginui.py layout page because if i comment out the code for the QGraphicsView Box then the QLineedit box gets focus as soon as the page is executed.

    and the second problem is the SQL select wont work for some unexplained weird reason

    I've attached all files if some one with some python experience can have a look at please. the script will create and sql lite database and then insert some data into it but it just wont select from it i don't even get an error message as I've tried to set up above to display what the problem is.

    Your help on this will be very appreciated, Thanks
    Attached Files Attached Files

  2. #2

    Default Re: More SQLite Woes and onFocus Woes

    thats sorted it

    ive sorted the SQlite problem out just needed to put single quotes around the query value and i needed to continue the sql object on to the error object and not try to create a totally new object.
    (still getting to grips with object oriented programing)

    Ive been following this book learning about PYQT, but Ive been following it to strictly because some of it has been done with out the proper syntax which has me thrown as im like well ive done what's in the book why ain't it working!?!?!? Any ways thanks


    Qt Code:
    1. def sqlEnterlogin(self):
    2. texer = self.lineEditer_login.text()
    3. query = QSqlQuery()
    4. query.exec_(unicode(QString("SELECT staff_id FROM staff WHERE password = '%1'").arg(texer))) ### %s" % (texer))
    5. if query.next():
    6. self.lineEditer_login.clear()
    7. texer2 = unicode(query.value(0).toString())
    8. self.lineEditer_login.setText("hello are you working? %s" % (texer2))
    9. ##self.emit(SIGNAL("loginSuccessful"))
    10. else:
    11. texer3 = query.lastError().text()
    12. self.lineEditer_login.setText("hello are you working22? %s" % (texer3))
    13. QApplication.processEvents()
    To copy to clipboard, switch view to plain text mode 

    but if any one has any solutions for why the QgraphicsView box is conflicting with the QLineEdit box then i would love to know about it
    thanks
    Last edited by morraine; 13th August 2008 at 14:38.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.