Results 1 to 20 of 38

Thread: subclass QLineEdit to have an index

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #8
    Join Date
    Apr 2016
    Posts
    32
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products

    Default Re: subclass QLineEdit to have an index

    Quote Originally Posted by anda_skoa View Post
    What does the class do with the index number?

    Cheers,
    _
    The class doesn't do anything with the index. I have a routine that creates a grid consisting of rows with a textbox followed by some labels. They are created in code using a series of for loops. If I can create a subclassed LineEdit(index) I will be able to use an existing routine written in VB6.


    Added after 6 minutes:


    Quote Originally Posted by d_stranz View Post
    Sounds to me like you are confusing how your program keeps track of multiple QLineEdit instances with the QLineEdit instances themselves. If you simply stick the QLineEdit pointers into a vector as you create them, then the index in the vector -is- the index of the QLineEdit. If all of your QLineEdit instances are connected to the same slot, then you can use the QObject::sender() method in the slot to get the pointer to the specific QLineEdit instance that sent the signal, and then search the vector to get the index.

    Or if your "index" is non-sequential, you can make a QMap< QWidget *, int > to map the QLineEdit pointer to any integer.

    Or you can use QSignalMapper to associate each QLineEdit instance with an integer.

    There are lots of ways to do what I think you are trying to do without having to make a custom widget.
    Thanks for the reply. I don't understand what you said so it doesn't help much. What is a vector? I appreciate the different methods to do what you think that I want to do, but what I really want is to know if it is possible to subclass a QLineEdit with an index and access it in this format: LineEdit(index) not LineEdit.index
    Last edited by nlgootee; 3rd May 2016 at 22:50.

Similar Threads

  1. Replies: 0
    Last Post: 11th June 2013, 10:50
  2. Replies: 2
    Last Post: 15th April 2013, 06:33
  3. Index out of bounds in custom QLayout subclass
    By space_otter in forum Qt Programming
    Replies: 1
    Last Post: 5th October 2011, 20:23
  4. Replies: 1
    Last Post: 12th January 2011, 22:40
  5. Replies: 8
    Last Post: 12th February 2010, 02:41

Tags for this Thread

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.