Results 1 to 8 of 8

Thread: how to know which QTextEdit i am using in tab widget

  1. #1
    Join Date
    Feb 2012
    Posts
    44
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Question how to know which QTextEdit i am using in tab widget

    I have a tab widget with no pages in that.at run time i will add a page to tab widget and in that page i will create dynamic QTextEdit like this if i add another page in tab widget with dynamic QTextEdit for newly created page and so on.....

    for example if i added four tabs(pages) in tab widget with dynamic QTextEdit for each page. If i want to access third tab(page) QTextEdit plain text i am using object of QTextEdit ->toPlainText(), when i am accessing this way, i am getting text from recently created dynamic QTextEdit which is under fourth tab.

    Now the problem is how to access QTextEdit which is under page1 and how to access QTextEdit under page2 and so on....

    please help me...............

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: how to know which QTextEdit i am using in tab widget

    You can store an array of those widgets somewhere, e.g. as a member variable of your form class.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Feb 2012
    Posts
    44
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: how to know which QTextEdit i am using in tab widget

    i have QTextEdit *txtedit object. with txtedit object , when ever i am creating a new page i am creating new QTextEdit with same object i.e txtedit = new QTextEdit(); i can't differentiate this object

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: how to know which QTextEdit i am using in tab widget

    An array, or a vector, or a list...

    such as QList<QTextEdit*>
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Jan 2012
    Location
    Dortmund, Germany
    Posts
    159
    Thanks
    69
    Thanked 10 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: how to know which QTextEdit i am using in tab widget

    as Wysota said: if your class has a member
    QVector <QTextEdit*> myPages;
    (e.g. in private: section of your header),
    you can add and remove the pointers to your pages to it.
    If you want to differentiate when using Signals and Slots, you can look the pointers up in your if you are inside your class.

    Outside your class you can use the ->data() variables for identifying.
    Therefore you setData(Qt::userRole+1) an identifying entry (e.g. QString: "Page1") at construction point of your pages.
    When receiving a signal you can then look up sender().data(Qt::userRole+1).toString().

  6. #6
    Join Date
    Feb 2012
    Posts
    44
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: how to know which QTextEdit i am using in tab widget

    thank you problem solved

    without inheriting QTextEdit how to use textchanged() signal

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: how to know which QTextEdit i am using in tab widget

    Exactly the same way as with inheriting. That has nothing to do with using signals.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  8. #8
    Join Date
    Jul 2012
    Posts
    17
    Thanks
    2
    Platforms
    Unix/X11 Windows

    Default Re: how to know which QTextEdit i am using in tab widget

    I made a Tab class with all widgets i wanted in it and a name parameter and gave every widget a unique name and stored it in a QList<myTabClass*>.
    The you may iterate through all Tabs and look up the name.

Similar Threads

  1. Replies: 3
    Last Post: 7th June 2012, 10:37
  2. Rotate QTextEdit Widget
    By lxman in forum Qt Programming
    Replies: 3
    Last Post: 10th February 2011, 13:18
  3. Replies: 2
    Last Post: 17th June 2010, 20:24
  4. Scrolling in QTextEdit Widget
    By ajb_advance in forum Newbie
    Replies: 2
    Last Post: 25th September 2007, 11:34
  5. Replies: 1
    Last Post: 16th February 2007, 07:22

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
  •  
Qt is a trademark of The Qt Company.