C++ (Qt)#include "mainwindow.h"#include "ui_mainwindow.h"#include "host.h"#include "QDebug"#include <QtGui>MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow){ //connect(port,SIGNAL(newDataInPortSignal(QTime,const unsigned char *, const int)),this, SLOT(receiveMsg(QTime,const unsigned char *, const int))); // Host::connect(&abc, SIGNAL(valueChanged(int)),this, SLOT(setValue(int))); //connect(&port, SIGNAL(valueChanged(int)),this, SLOT(setValue(int))); ui->setupUi(this); Qt::WindowFlags flags = 0; flags = Qt::Popup; QWidget::setWindowFlags(flags); QWidget::showFullScreen(); QTimer *timer = new QTimer(this); connect(timer, SIGNAL(timeout()), this, SLOT(update())); timer->start(1000); } MainWindow::~MainWindow(){ delete ui;} void MainWindow::logData(double zen,double az,double ot,int stkov){ QString azm, otk, zeni; zeni=zeni.setNum(zen); azm=azm.setNum(az); otk=otk.setNum(ot); ui->zenit->setText(zeni);ui->azimut->setText(azm);ui->otklonitel->setText(otk);ui->signal->setText("");if(stkov==0){ ui->stk->setText("No");}else if(stkov==1){ ui->stk->setText("Yes"); }} void MainWindow::onsysmsg(QString Smsg){ if(Smsg=="Timeout occurred.") ui->signal->setText(QString::fromLocal8Bit("No signal")); //ui->mytxt->setPlainText(Smsg); } void MainWindow::paintEvent(QPaintEvent *) { static const QPoint minuteHand[3] = { QPoint(7, 8), QPoint(-7, 8), QPoint(0, -70) }; QColor minuteColor(127, 0, 127); QColor hourColor (0, 127, 127); int side = qMin(width(), height()); QTime time = QTime::currentTime(); QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing); painter.translate(width() / 2, height() / 2); // По центру painter.scale(side / 300.0, side / 300.0); //Маштабируемость painter.setPen(Qt::NoPen); painter.setPen(hourColor); for (int i = 0; i < 90; ++i) { painter.drawLine(88, 0, 96, 0); painter.rotate(4.0); } painter.setPen(Qt::NoPen); painter.setBrush(minuteColor); painter.save();painter.rotate(6.0 * (time.minute() + time.second() / 60.0)); painter.drawConvexPolygon(minuteHand, 3); painter.restore(); painter.setPen(minuteColor); }
class canvas : public QWidget { Q_OBJECTpublic: canvas(QWidget* parent=0):QWidget(parent){} ~canvas(){}protected: void paintEvent(QPaintEvent*); //само рисование в другом месте создается, вы его наблюдали выше. Только вместо QTabWidget canvas};
Cint addTab ( QWidget * page, const QString & label )
QWidget q;ui->tabWidget->addTab(q,"tab_5");
C++ (Qt)QWidget* wt = new QWidget;ui->tabWidget->addTab(wt, "tab_5");