Results 1 to 4 of 4

Thread: [Qt 4.1.0] Split a widget on demand

  1. #1
    Join Date
    Jan 2006
    Location
    Curitiba - Brazil
    Posts
    23
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question [Qt 4.1.0] Split a widget on demand

    Hi all,
    I have the following problem:

    I have a widget and user could go to menu em choose "Split horizontal" or "Split vertical";
    as he do that each splitted widget could be splitted another time and thats all.
    So I have this:
    Qt Code:
    1. +-----------+
    2. | |
    3. | |
    4. | |
    5. +-----------+
    To copy to clipboard, switch view to plain text mode 
    than if user split horizontaly he should have this:
    Qt Code:
    1. +-----+-----+
    2. | | |
    3. | | |
    4. | | |
    5. +-----+-----+
    To copy to clipboard, switch view to plain text mode 
    At this point each splitted widget could be splitted one more time but only on vertical. Lets split left widget:
    Qt Code:
    1. +-----+-----+
    2. | | |
    3. +-----+ |
    4. | | |
    5. +-----+-----+
    To copy to clipboard, switch view to plain text mode 
    Ok now that I explain myself, lets to the real problem:
    I have a widget that extens QSplitter and on its constructor I add one widget. So far so good...
    But when I try to add another widget outside constructor, it not show the new widget and worst, if I try to delete an existen one, the program crashes.

    The question is:
    How do I add widgets on demand on a QSplitter and how do I delete the existen ones?
    --
    Thiago dos Santos Alves
    Computer Scientist

    thiago.salves@gmail.com
    -----------------------------------------------------
    "A mind that opens to a new idea never gets its original size again."
    - Albert Einstein

  2. #2
    Join Date
    Jan 2006
    Location
    Ukraine,Lviv
    Posts
    454
    Thanks
    9
    Thanked 27 Times in 27 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: [Qt 4.1.0] Split a widget on demand

    May we see your code? It will be very helful.
    a life without programming is like an empty bottle

  3. #3
    Join Date
    Jan 2006
    Location
    Curitiba - Brazil
    Posts
    23
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: [Qt 4.1.0] Split a widget on demand

    Its something like this:

    Qt Code:
    1. class MySplitter : public QSplitter {
    2. public:
    3. MySplitter(QWidget *parent = 0) : QSplitter(parent) {
    4. QTextEdit *editor = new QTextEdit(this);
    5. addWidget(editor);
    6. }
    7.  
    8. public slots:
    9. void splitHorizontal() {
    10. QTextEdit *editor = new QTextEdit(this);
    11. addWidget(editor);
    12. }
    13. };
    To copy to clipboard, switch view to plain text mode 

    this simple code doesn't work!
    --
    Thiago dos Santos Alves
    Computer Scientist

    thiago.salves@gmail.com
    -----------------------------------------------------
    "A mind that opens to a new idea never gets its original size again."
    - Albert Einstein

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

    Default Re: [Qt 4.1.0] Split a widget on demand

    Call "editor->show();".

Similar Threads

  1. QDockWidget inside another widget in the center?
    By Antebios in forum Qt Programming
    Replies: 1
    Last Post: 16th February 2010, 08:06
  2. Tricky problem with ARGB widget / UpdateLayeredWindow
    By nooky59 in forum Qt Programming
    Replies: 3
    Last Post: 21st February 2008, 11:35
  3. advanced split widget
    By vitaly in forum Qt Programming
    Replies: 10
    Last Post: 24th January 2006, 21:00

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.