Results 1 to 8 of 8

Thread: Custom widget

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Custom widget

    Could you provide a minimal compilable example reproducing the problem?

  2. #2
    Join Date
    Jan 2007
    Posts
    95
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    5

    Default Re: Custom widget

    I have been clean the programm.....

    Here you are...
    Attached Files Attached Files

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

    Default Re: Custom widget

    You didn't add the splitter into the widget's layout.

  4. #4
    Join Date
    Jan 2007
    Posts
    95
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    5

    Default Re: Custom widget

    I have just change the code of my custom widget constructor with (I think is that you are telling me):

    Qt Code:
    1. editor1 = new QTextEdit;
    2. editor2 = new QTextEdit;
    3. editor3 = new QTextEdit;
    4. splitter = new QSplitter (Qt::Horizontal);//--->change
    5. splitter->addWidget(editor1);
    6. splitter->addWidget(editor2);
    7. splitter->addWidget(editor3);
    8. QVBoxLayout *vbox = new QVBoxLayout; //new
    9. vbox->addWidget(splitter); //new
    10. this->setLayout(vbox); //new
    To copy to clipboard, switch view to plain text mode 

    And the box is bigger but only shows one white box (text editor) and can't do anything in it (can't write....), and the box do not resize when i resize the mainwindow.

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

    Default Re: Custom widget

    For me it seems your class is completely broken.

    You should implement it like so:

    Qt Code:
    1. #include <QtGui>
    2.  
    3. class X : public QSplitter {
    4. public:
    5. X() : QSplitter(Qt::Horizontal){
    6. addWidget(new QTextEdit);
    7. addWidget(new QTextEdit);
    8. addWidget(new QTextEdit);
    9. }
    10.  
    11. };
    12.  
    13. int main(int argc, char **argv){
    14. QApplication app(argc, argv);
    15. X edit;
    16. edit.show();
    17. return app.exec();
    18. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. custom plug-in widget in another custom plug-in widget.
    By MrGarbage in forum Qt Programming
    Replies: 6
    Last Post: 27th August 2007, 16:38
  2. Simple custom widget won't size properly
    By MrGarbage in forum Qt Tools
    Replies: 2
    Last Post: 9th August 2007, 14:12
  3. Custom tab widget question
    By PrimeCP in forum Qt Programming
    Replies: 2
    Last Post: 7th August 2007, 12:17
  4. Problem applying setWindowOpacity to a custom Widget
    By yellowmat in forum Qt Programming
    Replies: 8
    Last Post: 1st November 2006, 11:05
  5. Replies: 4
    Last Post: 24th March 2006, 23:50

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.