Re: [Interest] QLineEdit and QTableWidget

2015-07-07 Thread Alejandro Exojo
El Tuesday 07 July 2015, Rene Decartes escribió:
 but it is turning out to be convoluted (for me!) am i approaching this
 correctly?

I'm not fully sure I undestand what you want, but, could it be that what you 
want is a grid layout instead?

-- 
Alex (a.k.a. suy) | GPG ID 0x0B8B0BC2
http://barnacity.net/ | http://disperso.net
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] QLineEdit and QTableWidget

2015-07-07 Thread Rene Decartes
tony, alex

i don't think a grid layout would work as i want to have a list (loosely 
worded) of items and a tablewidget seems to be the logical choice.

the goal is to display attributes from a database table which has three 
attributes, key, number, name. i would like to put the number and name from the 
database in a tablewidget based on a sql select by key. my thought is to have a 
lineedit for each entry. each lineedit would in turn would be placed in a 
tablewidgetitem. the tablewidget would have a single column. there would be a 
final empty tablewidgetitem as the last row in the tablewidget to allow for 
adding an additional name to the database table. after a new name is entered in 
the last item, a signal would cause another empty item/row to be created. the 
salient point is that the last item should use sqltablemodel, tableview and 
completer to allow the user to select a name from a list of names (and numbers) 
in a separate database table. all tablewidgetitems should use the same 
model/view/completer scheme.

the model/view/completer code in the prior post is how i would implement the 
model/view/completer for a lineedit in each tablewidgetitem.

my question is should i be using a custom itemdelegate and custom 
tablewidgetitem as used in the qt spreadsheet example. would the lineedit be 
coded in the custom tablewidgetitem?
-- 
thanks
allen

There are 10 kinds of people. Those who understand binary code, and those who 
do not.

On Tue, 7 Jul 2015 13:45:36 +0200
Alejandro Exojo s...@badopi.org wrote:

 El Tuesday 07 July 2015, Rene Decartes escribió:
  but it is turning out to be convoluted (for me!) am i approaching this
  correctly?
 
 I'm not fully sure I undestand what you want, but, could it be that what you 
 want is a grid layout instead?
 
 -- 
 Alex (a.k.a. suy) | GPG ID 0x0B8B0BC2
 http://barnacity.net/ | http://disperso.net

On Wed, 8 Jul 2015 01:03:52 +1000
Tony Rietwyk t...@rightsoft.com.au wrote:

 Hi allen, 
 
  what i really want is to be able to
  attach multiple persons rather a single one with each item in the (say,
  household) widget. so i thought to use a single column table widget and
  follow the spreadsheet example to create the table, delegate and item
  widgets putting the above line edit each item widget.
 
 I'm confused by your last line.  Do you want separate line edits to appear
 on each row (create each and use view.setItemWidget), or just the current
 row (delegate should be doing this already?), or hovering over the previous
 to current row? 
 
 But the start of your requirement sounds more like a combo box that
 automatically adds items.  So instead of the delegate creating an edit box
 on the current string item, it creates a combo box instead and the item's
 value is a string list of people? 
 
 Hope that helps, 
 
 Tony
 
 
  -Original Message-
  From: interest-bounces+tony=rightsoft.com...@qt-project.org
  [mailto:interest-bounces+tony=rightsoft.com...@qt-project.org] On Behalf
  Of Rene Decartes
  Sent: Tuesday, 7 July 2015 12:41 PM
  To: interest@qt-project.org
  Subject: [Interest] QLineEdit and QTableWidget
  
  hello,
  
  i rather green at using qt. jumping right in, i had a qlineedit on a
 widget that is
  basically coded as:
  
  People::createPersonEdit()
  {
  personEdit = new QLineEdit ;
  personLabel = new QLabel( tr( Person: ) ) ;
  personLabel-setBuddy( personEdit ) ;
  
  personModel = new QSqlQueryModel( this ) ;
  personModel-setQuery( SELECT number , name FROM someTable
  WHERE number  -1 ORDER BY name ) ;
  
  personCompleter = new QCompleter( this ) ;
  personCompleter-setModel( personModel ) ;
  
  personView = new QTableView ;
  personCompleter-setPopup( personView ) ;
  
  int width = personView-columnWidth( 0  ) ;
  width += personView-columnWidth( 1  ) ;
  
  personView-setColumnHidden( 0 , true ) ;
  personView-setColumnWidth( 1 , width ) ;
  
  personEdit-setCompleter( personCompleter ) ;
  
  connect( personEdit , SIGNAL( editingFinished() ) ,
   this , SLOT( personValidate() ) ) ; } what i really want is
 to be able to
  attach multiple persons rather a single one with each item in the (say,
  household) widget. so i thought to use a single column table widget and
  follow the spreadsheet example to create the table, delegate and item
  widgets putting the above line edit each item widget.
  
  but it is turning out to be convoluted (for me!) am i approaching this
 correctly?
  
  --
  allen
  
  There are 10 kinds of people. Those who do understand binary code, and
  those who do not.
  ___
  Interest mailing list
  Interest@qt-project.org
  http://lists.qt-project.org/mailman/listinfo/interest
 
 ___
 Interest mailing list
 Interest@qt-project.org
 http://lists.qt-project.org/mailman/listinfo/interest
-- 
rd

There are 10 kinds of people. Those who

Re: [Interest] QLineEdit and QTableWidget

2015-07-07 Thread Tony Rietwyk
Hi allen, 

 what i really want is to be able to
 attach multiple persons rather a single one with each item in the (say,
 household) widget. so i thought to use a single column table widget and
 follow the spreadsheet example to create the table, delegate and item
 widgets putting the above line edit each item widget.

I'm confused by your last line.  Do you want separate line edits to appear
on each row (create each and use view.setItemWidget), or just the current
row (delegate should be doing this already?), or hovering over the previous
to current row? 

But the start of your requirement sounds more like a combo box that
automatically adds items.  So instead of the delegate creating an edit box
on the current string item, it creates a combo box instead and the item's
value is a string list of people? 

Hope that helps, 

Tony


 -Original Message-
 From: interest-bounces+tony=rightsoft.com...@qt-project.org
 [mailto:interest-bounces+tony=rightsoft.com...@qt-project.org] On Behalf
 Of Rene Decartes
 Sent: Tuesday, 7 July 2015 12:41 PM
 To: interest@qt-project.org
 Subject: [Interest] QLineEdit and QTableWidget
 
 hello,
 
 i rather green at using qt. jumping right in, i had a qlineedit on a
widget that is
 basically coded as:
 
 People::createPersonEdit()
 {
 personEdit = new QLineEdit ;
 personLabel = new QLabel( tr( Person: ) ) ;
 personLabel-setBuddy( personEdit ) ;
 
 personModel = new QSqlQueryModel( this ) ;
 personModel-setQuery( SELECT number , name FROM someTable
 WHERE number  -1 ORDER BY name ) ;
 
 personCompleter = new QCompleter( this ) ;
 personCompleter-setModel( personModel ) ;
 
 personView = new QTableView ;
 personCompleter-setPopup( personView ) ;
 
 int width = personView-columnWidth( 0  ) ;
 width += personView-columnWidth( 1  ) ;
 
 personView-setColumnHidden( 0 , true ) ;
 personView-setColumnWidth( 1 , width ) ;
 
 personEdit-setCompleter( personCompleter ) ;
 
 connect( personEdit , SIGNAL( editingFinished() ) ,
  this , SLOT( personValidate() ) ) ; } what i really want is
to be able to
 attach multiple persons rather a single one with each item in the (say,
 household) widget. so i thought to use a single column table widget and
 follow the spreadsheet example to create the table, delegate and item
 widgets putting the above line edit each item widget.
 
 but it is turning out to be convoluted (for me!) am i approaching this
correctly?
 
 --
 allen
 
 There are 10 kinds of people. Those who do understand binary code, and
 those who do not.
 ___
 Interest mailing list
 Interest@qt-project.org
 http://lists.qt-project.org/mailman/listinfo/interest

___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


[Interest] QLineEdit and QTableWidget

2015-07-06 Thread Rene Decartes
hello,

i rather green at using qt. jumping right in, i had a qlineedit on a widget 
that is basically coded as:

People::createPersonEdit()
{
personEdit = new QLineEdit ;
personLabel = new QLabel( tr( Person: ) ) ;
personLabel-setBuddy( personEdit ) ;

personModel = new QSqlQueryModel( this ) ;
personModel-setQuery( SELECT number , name FROM someTable WHERE number  
-1 ORDER BY name ) ;

personCompleter = new QCompleter( this ) ;
personCompleter-setModel( personModel ) ;

personView = new QTableView ;
personCompleter-setPopup( personView ) ;

int width = personView-columnWidth( 0  ) ;
width += personView-columnWidth( 1  ) ;

personView-setColumnHidden( 0 , true ) ;
personView-setColumnWidth( 1 , width ) ;

personEdit-setCompleter( personCompleter ) ;

connect( personEdit , SIGNAL( editingFinished() ) ,
 this , SLOT( personValidate() ) ) ;
}
what i really want is to be able to attach multiple persons rather a single one 
with each item in the (say, household) widget. so i thought to use a single 
column table widget and follow the spreadsheet example to create the table, 
delegate and item widgets putting the above line edit each item widget. 

but it is turning out to be convoluted (for me!) am i approaching this 
correctly?

-- 
allen

There are 10 kinds of people. Those who do understand binary code, and those 
who do not.
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest