Results 1 to 11 of 11

Thread: how to change 1st mainwindow's frame by 2nd window's frame

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2018
    Posts
    6
    Qt products
    Qt4 Qt5

    Default how to change 1st mainwindow's frame by 2nd window's frame

    Hi,

    i'm new in qt. and i have a minwindow and a second window. the 1st window has 3 frames and the 2nd has only one. my question: how to swap after clicked a button the 2nd window's frame with the 3rd frame of the 1st window? here are my codes:

    Qt Code:
    1. .h
    2. #ifndef FIRSTDIALOG_H
    3. #define FIRSTDIALOG_H
    4.  
    5. #include <QDialog>
    6. #include <QFrame>
    7. #include <QWidget>
    8. #include <QListWidgetItem>
    9.  
    10. namespace Ui {
    11. class FirstDialog;
    12. }
    13.  
    14. class FirstDialog : public QDialog
    15. {
    16. Q_OBJECT
    17.  
    18. public:
    19. explicit FirstDialog(QWidget *parent = 0);
    20. ~FirstDialog();
    21.  
    22. private:
    23. Ui::FirstDialog *ui;
    24. QFrame *frame_4;
    25. };
    26.  
    27. #endif // FIRSTDIALOG_H
    28.  
    29. //---------------------------------------------
    30. .cpp
    31. #include "firstdialog.h"
    32. #include "ui_firstdialog.h"
    33. #include <QWidget>
    34.  
    35. FirstDialog::FirstDialog(QWidget *parent) :
    36. QDialog(parent),
    37. ui(new Ui::FirstDialog)
    38. {
    39. ui->setupUi(this);
    40. }
    41.  
    42. FirstDialog::~FirstDialog()
    43. {
    44. delete ui;
    45. }
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. .h
    2. #ifndef MAINWINDOW_H
    3. #define MAINWINDOW_H
    4.  
    5. #include <QMainWindow>
    6. #include <QLabel>
    7. //#include <QListWidget>
    8. //#include <QWidget>
    9. #include <QListWidgetItem>
    10.  
    11. namespace Ui {
    12. class MainWindow;
    13. }
    14.  
    15. class MainWindow : public QMainWindow
    16. {
    17. Q_OBJECT
    18.  
    19. public:
    20. explicit MainWindow(QWidget *parent = 0);
    21. ~MainWindow();
    22.  
    23. private slots:
    24. void on_pushButton_1_clicked();
    25.  
    26. private:
    27. Ui::MainWindow *ui;
    28. QFrame *frame_1;
    29. QFrame *frame_2;
    30. QFrame *frame_3;
    31. };
    32.  
    33. #endif // MAINWINDOW_H
    34. //-------------------------------------------
    35. .cpp
    36. #include "mainwindow.h"
    37. #include "ui_mainwindow.h"
    38. #include "firstdialog.h"
    39. #include <QLabel>
    40. #include <QPixmap>
    41.  
    42. MainWindow::MainWindow(QWidget *parent) :
    43. QMainWindow(parent),
    44. ui(new Ui::MainWindow)
    45. {
    46. ui->setupUi(this);
    47. QPixmap pix("C:/Users/Infonet/Documents/frames_test/logo6_DT.png");
    48. int w = ui->label_1->width();
    49. int h = ui->label_1->height();
    50. ui->label_1->setPixmap(pix.scaled(w,h,Qt::KeepAspectRatio));
    51. }
    52.  
    53. MainWindow::~MainWindow()
    54. {
    55. delete ui;
    56. }
    57.  
    58. void MainWindow::on_pushButton_1_clicked()
    59. {
    60. FirstDialog *firstdia = new FirstDialog;
    61. firstdia->show();
    62. }
    To copy to clipboard, switch view to plain text mode 

    thanks.
    Last edited by doubw; 10th December 2018 at 07:00.

Similar Threads

  1. Replies: 1
    Last Post: 5th December 2013, 06:46
  2. Frame-by-frame event handling?
    By QTNovice in forum Qt Programming
    Replies: 1
    Last Post: 28th October 2013, 22:32
  3. Video Parsing - Frame by Frame
    By ctote in forum Qt Programming
    Replies: 3
    Last Post: 15th February 2010, 18:30
  4. Previous frame inner to this frame(corrupt stack?)
    By coralbird in forum Qt Programming
    Replies: 1
    Last Post: 28th May 2007, 01:35
  5. Previous frame inner to this frame(corrupt stack?)
    By coralbird in forum Qt Programming
    Replies: 17
    Last Post: 29th April 2006, 01:42

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.