Results 1 to 4 of 4

Thread: QLabel| Pixmap Delay

  1. #1
    Join Date
    Jan 2015
    Posts
    5
    Thanks
    2
    Qt products
    Qt3
    Platforms
    Windows

    Default QLabel| Pixmap Delay

    Hello, i created a clickable labels in pixmap, but delay has occurred to open form. Code bellow:

    Qt Code:
    1. #include "secdialog.h"
    2. #include "ui_secdialog.h"
    3. #include <QPixmap>
    4.  
    5.  
    6. SecDialog::SecDialog(QWidget *parent) :
    7. QDialog(parent),
    8. ui(new Ui::SecDialog)
    9. {
    10. ui->setupUi(this);
    11.  
    12.  
    13. QPixmap pix("C:\\Users\\Edilson\\Documents\\Menu_Inicio\\Imagens\\PratosQuentes.jpg");
    14. ui->label_2->setPixmap(pix);
    15.  
    16. QPixmap pix2("C:\\Users\\Edilson\\Documents\\Menu_Inicio\\Imagens\\PratosFrios.jpg");
    17. ui->label_3->setPixmap(pix2);
    18.  
    19. QPixmap pix3("C:\\Users\\Edilson\\Documents\\Menu_Inicio\\Imagens\\porcoes.jpg");
    20. ui->label_4->setPixmap(pix3);
    21.  
    22. QPixmap pix4("C:\\Users\\Edilson\\Documents\\Menu_Inicio\\Imagens\\Pizzas.jpg");
    23. ui->label_5->setPixmap(pix4);
    24.  
    25. QPixmap pix5("C:\\Users\\Edilson\\Documents\\Menu_Inicio\\Imagens\\Lanches.jpg");
    26. ui->label_6->setPixmap(pix5);
    27.  
    28. QPixmap pix6("C:\\Users\\Edilson\\Documents\\Menu_Inicio\\Imagens\\Bebidas.jpg");
    29. ui->label_7->setPixmap(pix6);
    30. }
    31.  
    32. SecDialog::~SecDialog()
    33. {
    34. delete ui;
    35. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QLabel| Pixmap Delay

    Nothing in the code you presented opens a form. Assuming this is the dialog you wish to display then its constructor looks OK (except for hard coded paths). There may be some time required to open and load (and probably scale) the image files (how big are they?) but it is incurred at object construction time,, not when you call show() or exec().

    Perhaps you could provide some information about the "Delay has occurred to open form", where you notice the delay, how you have measured it, and what you have done to isolate it.

  3. #3
    Join Date
    Jan 2015
    Posts
    5
    Thanks
    2
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: QLabel| Pixmap Delay

    Sorry brah.

    Code bellow:

    Qt Code:
    1. void MainWindow::on_pushButton_2_clicked()
    2. {
    3. this->close();//Close the mainwindow and open the SecDialog
    4. SecDialog dialog(this);
    5. dialog.exec();
    6. }
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QLabel| Pixmap Delay

    Qt Code:
    1. this->close();//Close the mainwindow and open the SecDialog
    To copy to clipboard, switch view to plain text mode 

    Ummm, if your intention is to hide the MainWindow, then you do not do this. In general, if you call the close() slot on the MainWindow and it is the only window visible for the app (which it probably is, since the dialog is not visible yet), the app will try to shut down. See QApplication::quitOnLastWindowClosed() - the default for this is true.

    If you want to hide the main window when the dialog is shown, then call hide(), not close(). This might be the cause of your delay problem, I don't know. All I know is that you have probably shut down the main window's event loop when you call close(), and the only thing that is keeping the app running is the fact that the dialog has it's own temporary event loop running.

    What are you going to do once the user closes the dialog? If you use hide(), your main window will be gone, the dialog is gone, but your app is still running with no way to make it visible again.
    Last edited by d_stranz; 30th January 2015 at 00:49.

Similar Threads

  1. Replies: 1
    Last Post: 3rd January 2014, 19:28
  2. QLabel->pixmap not scaling properly and breaking the layout
    By Jon Heron in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 21st November 2010, 15:54
  3. QLabel and its content (pixmap) position problem.
    By miqqo in forum Qt Programming
    Replies: 1
    Last Post: 21st September 2010, 09:57
  4. Pixmap updating QLabel
    By Matt in forum Newbie
    Replies: 11
    Last Post: 17th August 2010, 21:11
  5. empty pixmap as a QLabel
    By tommy in forum Qt Programming
    Replies: 16
    Last Post: 11th December 2007, 21:15

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.