Results 1 to 2 of 2

Thread: QT ImageViewer Tutorial crashes with QT Designer

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2017
    Posts
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default QT ImageViewer Tutorial crashes with QT Designer

    My development environment is Visual studio 2015 with QT 5.6.3. I am creating forms using QT designer. I am doing several QT tutorials; specifically I am doing the following tutorial.

    http://www.bogotobogo.com/Qt/Qt5_QMa...geViewer_B.php

    The program essentially, displays an image using QScrollArea and QLabel. The program works if I create my "widgets" in visual studio (without QT designer)

    //Here's the relevant code
    Qt Code:
    1. imageLabel = new QLabel;
    2. imageLabel->setBackgroundRole(QPalette::Base);
    3. imageLabel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
    4. imageLabel->setScaledContents(true);
    5.  
    6. scrollArea = new QScrollArea;
    7. scrollArea->setBackgroundRole(QPalette::Dark);
    8. scrollArea->setWidget(imageLabel);
    9. setCentralWidget(scrollArea);
    To copy to clipboard, switch view to plain text mode 

    As expected the scrollbars appear.

    Then I created the widgets in QT Designer and tried to use it in visual studio. The one thing I noticed is that when I create a scrollArea using QT designer it also creates a QWidget called "ScrollAreaWidgetContents". See the attached "QT_Designer_1" and "QT_Inspector_Window" images. The problem is that I can't see scroll bars with this program. See the attached "Image_Viewer_No_ScrollBars". Here's the releavant code.

    Qt Code:
    1. ui->label->setBackgroundRole(QPalette::Base);
    2. ui->label->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
    3. ui->label->setScaledContents(true);
    4.  
    5. ui->scrollArea->setBackgroundRole(QPalette::Dark);
    6. ui->scrollArea->setWidget(ui->scrollAreaWidgetContents);
    7. ui->scrollArea->setWidgetResizable(true);
    8. ui->scrollAreaWidgetContents->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
    9. //ui->scrollArea->setWidget(ui->label);
    10. setCentralWidget(ui->scrollArea);
    To copy to clipboard, switch view to plain text mode 

    I then tried to uncomment "ui->scrollArea->setWidget(ui->label)" line and the program crashes. See the attached "Image_Viewer_Crashes" I guess I don't understand why it's crashing. Could anyone help resolve this problem?

    Thanks
    Attached Images Attached Images

Similar Threads

  1. Designer plugin crashes when opening *.ui
    By dimm0n in forum Qt Tools
    Replies: 2
    Last Post: 12th April 2010, 07:40
  2. plugin crashes designer but not app
    By jayw710 in forum Qt Tools
    Replies: 1
    Last Post: 27th June 2007, 19:37
  3. Simple text editor with QT designer Tutorial
    By overcast in forum Qt Tools
    Replies: 2
    Last Post: 27th January 2007, 14:33
  4. tutorial qt designer
    By edancorr in forum Qt Programming
    Replies: 1
    Last Post: 26th October 2006, 19:07
  5. Interesting tutorial on UI Designer
    By GreyGeek in forum Qt Tools
    Replies: 1
    Last Post: 6th August 2006, 08:43

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.