LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-25-2016, 07:54 PM   #1
Zero4
Member
 
Registered: Jun 2007
Posts: 71

Rep: Reputation: 0
PyQt4


hi
I an trying to get a global variable(string) to display in a textbox using PyQt4 it works in a script but not in an object orientened fashion

This is the problem line of code
Code:
 
textbox = QtGui.QLineEdit(self, glogal_variable)
textbox.move(100,100)
This is the error
Code:
TypeError: argument does not match any overload call
Thank you for your help
 
Old 11-25-2016, 07:56 PM   #2
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,223

Rep: Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320
Well, let's start with an easy question. Which of the two lines is the error message referring to? You should be able to tell from the rest of the error message. That information should be in the lines that you mistakenly thought were not important enough to share.

Last edited by dugan; 11-25-2016 at 08:00 PM.
 
1 members found this post helpful.
Old 11-25-2016, 10:06 PM   #3
Zero4
Member
 
Registered: Jun 2007
Posts: 71

Original Poster
Rep: Reputation: 0
This line
textbox = QtGui.QLineEdit(self, glogal_variable)
 
Old 11-26-2016, 02:06 AM   #4
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,223

Rep: Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320
Quote:
Originally Posted by Zero4 View Post
This line
textbox = QtGui.QLineEdit(self, glogal_variable)
Well, you can see from the official Qt 4 documentation that QLineEdit has two overloaded constructors:
  1. where you pass in the QLineEdit's parent widget
  2. where you pass in the text value, followed by the parent widget

Source:
http://doc.qt.io/qt-4.8/qlineedit.html

Now, I assume that "glogal_variable" is the value and "self" is the parent. If so, then you need to reverse their order.

Code:
textbox = QtGui.QLineEdit(glogal_variable, self)
If I recall correctly, the list of overloads would have been in the information that you didn't post

Last edited by dugan; 11-26-2016 at 12:24 PM.
 
Old 11-26-2016, 07:53 PM   #5
Zero4
Member
 
Registered: Jun 2007
Posts: 71

Original Poster
Rep: Reputation: 0
Hi
I have tried reversing them as you suggest, Didn't work!

Is this the info you require

QLineEdit(QWidget parent=None): too many arguments
QLineEdit(QString, QWidget parent=None): argument 1 has unexpected type "window"
 
Old 11-26-2016, 09:04 PM   #6
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,263
Blog Entries: 24

Rep: Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194
Quote:
Originally Posted by Zero4 View Post
Hi
I have tried reversing them as you suggest, Didn't work!
"Didn't work!" does not help others to understand what is happening on your system.

Please see the site FAQ, especially here and What makes a good issue description for guidance on posting your question.

Dugan's suggestion was based on a clearly stated assumption about the information not supplied in your original question. Did you read and understand the QT QLineEdit documentation in the link he provided? Do you know the types of the arguments that you are passing to it?

Quote:
Originally Posted by Zero4 View Post
QLineEdit(QWidget parent=None): too many arguments
QLineEdit(QString, QWidget parent=None): argument 1 has unexpected type "window"
That is clearly telling you that the type of the first argument being passed is not of type QString.

But it is also not clear from your sparse information whether this message was produced before or after you reversed the order of the arguments which didn't work, and which are still of types unknown to anyone here...

So please restate your problem description and provide the complete picture, including the intended overload prototype, the type definitions of each of the arguments being passed, and the complete error messages that result.

Last edited by astrogeek; 11-26-2016 at 09:07 PM. Reason: Remove sig
 
Old 11-27-2016, 10:20 AM   #7
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,223

Rep: Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320
Quote:
Originally Posted by Zero4 View Post
I have tried reversing them as you suggest, Didn't work!

Is this the info you require

QLineEdit(QWidget parent=None): too many arguments
QLineEdit(QString, QWidget parent=None): argument 1 has unexpected type "window
No, that's not enough. And with the way communications with you are going, nothing but the following will be:

You need to post a full program that demonstrates the problem you're having. If your program is long, reduce it to just something that both a) is runnable and b) demonstrates the problem. Then post both that, and the full output from running it. I need to be able to see the line numbers in the error output and match them to what I see in the source code.

You have been redacting a lot of information from your error output. Stop doing that.

Last edited by dugan; 11-27-2016 at 01:18 PM.
 
Old 11-27-2016, 07:37 PM   #8
Zero4
Member
 
Registered: Jun 2007
Posts: 71

Original Poster
Rep: Reputation: 0
All i would like to know is it possible to display the content of a global variable in "QtGui.QLineEdit()"
function. Alternatively, a label.
 
Old 11-27-2016, 09:05 PM   #9
notKlaatu
Senior Member
 
Registered: Sep 2010
Location: Lawrence, New Zealand
Distribution: Slackware
Posts: 1,077

Rep: Reputation: 732Reputation: 732Reputation: 732Reputation: 732Reputation: 732Reputation: 732Reputation: 732
Quote:
Originally Posted by Zero4 View Post
All i would like to know is it possible to display the content of a global variable in "QtGui.QLineEdit()"
function. Alternatively, a label.
Yes, it is. Both.

For debugging output, though, you have to post more than two lines of code without context.
 
Old 11-27-2016, 11:57 PM   #10
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,223

Rep: Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320
Quote:
Originally Posted by Zero4 View Post
All i would like to know is it possible to display the content of a global variable in "QtGui.QLineEdit()"
function. Alternatively, a label.
The answer is yes.

Is that really all you wanted to know? If yes, marked the thread as Solved.

If you also want to know why it wasn't working for you, then post the information asked for.

Last edited by dugan; 12-06-2016 at 02:58 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] PyQt4 QTableWidget with QComboBox sharky Programming 1 07-10-2016 12:23 PM
[SOLVED] PySide vs PyQt4 problem sharky Programming 5 06-24-2014 01:41 PM
How do I know if I have PyQT4 installed using Ubuntu? ShaqDiesel Ubuntu 1 05-15-2013 01:37 PM
[SOLVED] PyQt4 Make errors asuderma Linux - Software 1 07-10-2012 12:37 AM
PyQt4 app broken MTK358 Programming 5 10-21-2010 10:13 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:07 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration