精华内容
下载资源
问答
  • TabWidget

    2021-01-07 09:06:48
    <p>Currently the TabWidget does not share values about tabs because setting them from the outside could lead into inconsistencies because i cannot get some change callbacks that hint the widget to ...
  • TabWidget实例

    2018-09-20 17:35:31
    TabWidget实例,多窗口组件实例,相关功能使用的实例.
  • 主要介绍了Android切换卡TabWidget用法,结合实例形式分析了TabWidget选项卡界面布局及功能实现的操作技巧,需要的朋友可以参考下
  • 主要为大家详细介绍了Android TabWidget底部显示效果的三种方式,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
  • 简单 TabWidget

    2015-01-05 14:25:21
     #include "mainwindow.h" #include int main(int argc, char *argv[]) { QApplication a(argc, argv); ... QTabWidget *m_tabWidget;... m_tabWidget = new QTabWidget(); Q
    
    #include "mainwindow.h"
    #include <QApplication>
    
    
    int main(int argc, char *argv[])
    {
        QApplication a(argc, argv);
    
    
        QTabWidget      *m_tabWidget;
        m_tabWidget = new QTabWidget();
    
    
        QIcon icon1(":/images/NOR.png");
        QLabel *label = new QLabel("Hello Qt");
        m_tabWidget->addTab(label,icon1,"Tab1");
        //m_tabWidget->addTab(label,"Tab1");
    
    
        m_tabWidget->show();
    
    
        return a.exec();
    }
    展开全文
  • <div><p>I have a TabWidget: <pre><code> pages := []TabPage tabLayout = TabWidget { Pages: pages } pages = append(pages, TabLayout { Title: "T1" } </code></pre> <p>The append has...
  • tabwidget.h

    2017-01-03 21:42:13
    #ifndef TABWIDGET_H #define TABWIDGET_H#include #include <QWebEnginePage>QT_BEGIN_NAMESPACE class QUrl; QT_END_NAMESPACEclass WebView;class TabWidget : public QTabWidget { Q_OBJECTpubl
    #ifndef TABWIDGET_H
    #define TABWIDGET_H
    
    #include <QTabWidget>
    #include <QWebEnginePage>
    
    QT_BEGIN_NAMESPACE
    class QUrl;
    QT_END_NAMESPACE
    
    class WebView;
    
    class TabWidget : public QTabWidget
    {
        Q_OBJECT
    
    public:
        TabWidget(QWidget *parent = nullptr);
        ~TabWidget();
    
        WebView *currentWebView() const;
    
    signals:
        // current tab/page signals
        void linkHovered(const QString &link);
        void loadProgress(int progress);
        void titleChanged(const QString &title);
        void urlChanged(const QUrl &url);
        void iconChanged(const QIcon &icon);
        void webActionEnabledChanged(QWebEnginePage::WebAction action, bool enabled);
    
    public slots:
        // current tab/page slots
        void setUrl(const QUrl &url);
        void triggerWebPageAction(QWebEnginePage::WebAction action);
    
        WebView *createTab(bool makeCurrent = true);
        void closeTab(int index);
        void nextTab();
        void previousTab();
    
    private slots:
        void handleCurrentChanged(int index);
        void handleContextMenuRequested(const QPoint &pos);
        void cloneTab(int index);
        void closeOtherTabs(int index);
        void reloadAllTabs();
        void reloadTab(int index);
    
    private:
        WebView *webView(int index) const;
        void setupView(WebView *webView);
    };
    
    #endif // TABWIDGET_H
    展开全文
  • 本篇文章小编为大家介绍,Android TabWidget切换卡的实现应用。需要的朋友参考下
  • tabwidget.cpp

    2017-01-03 21:43:01
    #include "tabwidget.h" #include "webpage.h" #include "webview.h" #include #include #include <QWebEngineProfile>TabWidget::TabWidget(QWidget *parent) : QTabWidget(parent) { QTa
    #include "tabwidget.h"
    #include "webpage.h"
    #include "webview.h"
    #include <QMenu>
    #include <QTabBar>
    #include <QWebEngineProfile>
    
    TabWidget::TabWidget(QWidget *parent)
        : QTabWidget(parent)
    {
        QTabBar *tabBar = this->tabBar();
        tabBar->setTabsClosable(true);
        tabBar->setSelectionBehaviorOnRemove(QTabBar::SelectPreviousTab);
        tabBar->setMovable(true);
        tabBar->setContextMenuPolicy(Qt::CustomContextMenu);
        connect(tabBar, &QTabBar::customContextMenuRequested, this, &TabWidget::handleContextMenuRequested);
        connect(tabBar, &QTabBar::tabCloseRequested, this, &TabWidget::closeTab);
        connect(tabBar, &QTabBar::tabBarDoubleClicked, [this](int index) {
            if (index != -1)
                return;
            createTab();
        });
    
        setDocumentMode(true);
        setElideMode(Qt::ElideRight);
    
        connect(this, &QTabWidget::currentChanged, this, &TabWidget::handleCurrentChanged);
    }
    
    TabWidget::~TabWidget()
    {
    }
    
    void TabWidget::handleCurrentChanged(int index)
    {
        if (index != -1) {
            WebView *view = webView(index);
            if (!view->url().isEmpty())
                view->setFocus();
            emit titleChanged(view->title());
            emit loadProgress(view->loadProgress());
            emit urlChanged(view->url());
            emit iconChanged(view->icon());
            emit webActionEnabledChanged(QWebEnginePage::Back, view->isWebActionEnabled(QWebEnginePage::Back));
            emit webActionEnabledChanged(QWebEnginePage::Forward, view->isWebActionEnabled(QWebEnginePage::Forward));
            emit webActionEnabledChanged(QWebEnginePage::Stop, view->isWebActionEnabled(QWebEnginePage::Stop));
            emit webActionEnabledChanged(QWebEnginePage::Reload,view->isWebActionEnabled(QWebEnginePage::Reload));
        } else {
            emit titleChanged(QString());
            emit loadProgress(0);
            emit urlChanged(QUrl());
            emit iconChanged(QIcon());
            emit webActionEnabledChanged(QWebEnginePage::Back, false);
            emit webActionEnabledChanged(QWebEnginePage::Forward, false);
            emit webActionEnabledChanged(QWebEnginePage::Stop, false);
            emit webActionEnabledChanged(QWebEnginePage::Reload, true);
        }
    }
    
    void TabWidget::handleContextMenuRequested(const QPoint &pos)
    {
        QMenu menu;
        menu.addAction(tr("New &Tab"), this, &TabWidget::createTab, QKeySequence::AddTab);
        int index = tabBar()->tabAt(pos);
        if (index != -1) {
            QAction *action = menu.addAction(tr("Clone Tab"));
            connect(action, &QAction::triggered, this, [this,index]() {
                cloneTab(index);
            });
            menu.addSeparator();
            action = menu.addAction(tr("&Close Tab"));
            action->setShortcut(QKeySequence::Close);
            connect(action, &QAction::triggered, this, [this,index]() {
                closeTab(index);
            });
            action = menu.addAction(tr("Close &Other Tabs"));
            connect(action, &QAction::triggered, this, [this,index]() {
                closeOtherTabs(index);
            });
            menu.addSeparator();
            action = menu.addAction(tr("Reload Tab"));
            action->setShortcut(QKeySequence::Refresh);
            connect(action, &QAction::triggered, this, [this,index]() {
                reloadTab(index);
            });
        } else {
            menu.addSeparator();
        }
        menu.addAction(tr("Reload All Tabs"), this, &TabWidget::reloadAllTabs);
        menu.exec(QCursor::pos());
    }
    
    WebView *TabWidget::currentWebView() const
    {
        return webView(currentIndex());
    }
    
    WebView *TabWidget::webView(int index) const
    {
        return qobject_cast<WebView*>(widget(index));
    }
    
    void TabWidget::setupView(WebView *webView)
    {
        QWebEnginePage *webPage = webView->page();
    
        connect(webView, &QWebEngineView::titleChanged, [this, webView](const QString &title) {
            int index = indexOf(webView);
            if (index != -1)
                setTabText(index, title);
            if (currentIndex() == index)
                emit titleChanged(title);
        });
        connect(webView, &QWebEngineView::urlChanged, [this, webView](const QUrl &url) {
            int index = indexOf(webView);
            if (index != -1)
                tabBar()->setTabData(index, url);
            if (currentIndex() == index)
                emit urlChanged(url);
        });
        connect(webView, &QWebEngineView::loadProgress, [this, webView](int progress) {
            if (currentIndex() == indexOf(webView))
                emit loadProgress(progress);
        });
        connect(webPage, &QWebEnginePage::linkHovered, [this, webView](const QString &url) {
            if (currentIndex() == indexOf(webView))
                emit linkHovered(url);
        });
        connect(webView, &WebView::iconChanged, [this, webView](const QIcon& icon) {
            int index = indexOf(webView);
            if (index != -1)
                setTabIcon(index, icon);
            if (currentIndex() == index)
                emit iconChanged(icon);
        });
        connect(webView, &WebView::webActionEnabledChanged, [this, webView](QWebEnginePage::WebAction action, bool enabled) {
            if (currentIndex() ==  indexOf(webView))
                emit webActionEnabledChanged(action,enabled);
        });
        connect(webView, &QWebEngineView::loadStarted, [this, webView]() {
            int index = indexOf(webView);
            if (index != -1) {
                QIcon icon(QLatin1String(":view-refresh.png"));
                setTabIcon(index, icon);
            }
        });
        connect(webPage, &QWebEnginePage::windowCloseRequested, [this, webView]() {
            int index = indexOf(webView);
            if (index >= 0)
                closeTab(index);
        });
    }
    
    WebView *TabWidget::createTab(bool makeCurrent)
    {
        WebView *webView = new WebView;
        WebPage *webPage = new WebPage(QWebEngineProfile::defaultProfile(), webView);
        webView->setPage(webPage);
        setupView(webView);
        addTab(webView, tr("(Untitled)"));
        if (makeCurrent)
            setCurrentWidget(webView);
        return webView;
    }
    
    void TabWidget::reloadAllTabs()
    {
        for (int i = 0; i < count(); ++i)
            webView(i)->reload();
    }
    
    void TabWidget::closeOtherTabs(int index)
    {
        for (int i = count() - 1; i > index; --i)
            closeTab(i);
        for (int i = index - 1; i >= 0; --i)
            closeTab(i);
    }
    
    void TabWidget::closeTab(int index)
    {
        if (WebView *view = webView(index)) {
            bool hasFocus = view->hasFocus();
            removeTab(index);
            if (hasFocus && count() > 0)
                currentWebView()->setFocus();
            if (count() == 0)
                createTab();
            view->deleteLater();
        }
    }
    
    void TabWidget::cloneTab(int index)
    {
        if (WebView *view = webView(index)) {
            WebView *tab = createTab(false);
            tab->setUrl(view->url());
        }
    }
    
    void TabWidget::setUrl(const QUrl &url)
    {
        if (WebView *view = currentWebView()) {
            view->setUrl(url);
            view->setFocus();
        }
    }
    
    void TabWidget::triggerWebPageAction(QWebEnginePage::WebAction action)
    {
        if (WebView *webView = currentWebView()) {
            webView->triggerPageAction(action);
            webView->setFocus();
        }
    }
    
    void TabWidget::nextTab()
    {
        int next = currentIndex() + 1;
        if (next == count())
            next = 0;
        setCurrentIndex(next);
    }
    
    void TabWidget::previousTab()
    {
        int next = currentIndex() - 1;
        if (next < 0)
            next = count() - 1;
        setCurrentIndex(next);
    }
    
    void TabWidget::reloadTab(int index)
    {
        if (WebView *view = webView(index))
            view->reload();
    }
    
    展开全文
  • 本文实例讲述了Android编程之TabWidget选项卡用法。分享给大家供大家参考,具体如下: 1 概览 TabWidget与TabHost。tab组件一般包括TabHost和TabWidget、FrameLayout,且TabWidget、FrameLayout属于TabHost。 是否...
  • Tabwidget TabHost

    2013-07-25 10:47:23
    实现同个页面选项卡切换的效果,tabwidget是布局中的一个标签,开发的时候比较傻逼。TabHost控件-&gt;TabWidget(必须命名为tabs)-&gt;FrameLayout(必须命名为tabcontent)。   转载个源码: &lt;?xml...

    实现同个页面选项卡切换的效果,tabwidget是布局中的一个标签,开发的时候比较傻逼。TabHost控件->TabWidget(必须命名为tabs)->FrameLayout(必须命名为tabcontent)。

     

    转载个源码:

    <?xml version="1.0" encoding="utf-8"?>

    <TabHost android:layout_width="fill_parent"

        android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/TabHost1">

        <TabWidget android:id="@android:id/tabs"

            android:layout_height="wrap_content" android:layout_width="fill_parent">

    </TabWidget>

        <FrameLayout android:id="@android:id/tabcontent"

            android:paddingTop="65px" android:layout_width="fill_parent" android:layout_height="fill_parent">

            <LinearLayout android:layout_height="wrap_content" android:id="@+id/Tab1" android:orientation="vertical" android:layout_width="fill_parent">

               <EditText android:layout_height="wrap_content" android:id="@+id/edtTab1" android:layout_width="fill_parent"></EditText>

               <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/btnTab1" android:text="Tab1"></Button>

            </LinearLayout>

            <LinearLayout android:layout_height="wrap_content" android:id="@+id/Tab2" android:layout_width="fill_parent" android:orientation="horizontal">

               <EditText android:layout_height="wrap_content" android:id="@+id/edtTab2" android:layout_width="wrap_content" android:layout_weight="300"></EditText>

               <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/btnTab2" android:text="Tab2"></Button></LinearLayout>

        </FrameLayout>

    </TabHost>

     

    大概就是这个样子

     

     

    选项卡切换时的事件,tabhost.setOnchangeListener

     

    这边有个源码是转载的,其实老转载听惭愧

    展开全文
  • 主要介绍了Android入门之TabHost与TabWidget,对于Android初学者有一定的学习借鉴价值,需要的朋友可以参考下
  • TabWidget 应用

    2012-01-17 22:50:05
    Android手机打电话的界面运用的的是一个TabWidget(切换卡),通过多个标签切换显示不同内容,这个效果比不同Activity 之间跳转要快,所以如果大家做应用要实现不同Activity的跳转,可以考虑下TabWidget。首先要使用...
  • pyqt5 TabWidget

    千次阅读 2017-06-26 08:54:51
    希望在一个图片窗口里利用tabwidget显示多幅图片,或者同时可显示图片和视频 图片显示通过:QGraphicsView, QGraphicsScene,QGraphicsPixmapItem 视频播放通过QMediaplayer from PyQt5 import QtWidgets,...
  • TabWidget切换卡

    2015-06-25 10:10:44
    TabWidget是一种控件,通过多种标签来切换显示不同的内容,一个TabWidget主要由一个TabHost来存放多个Tab标签容器,再在Tab容器中加入其它控件,通过addTab方法可以增加新的Tab。这些除了在xml文件中布置好控件外,...
  • 多行TabWidget组件

    2015-04-15 11:16:12
    android.widget.TabWidget组件继承自LinearLayout,默认水平布局横向显示多个Tab(改垂直布局似乎就不能正常显示了)。如果要显示多行,每行水平分布若干个Tab,TabWidget是无能为力的。我继承TabWidget实现了一个...
  • tabwidget的tab隐藏问题

    2020-05-28 10:22:20
    tabWidget->setTabEnabled(0,false); ui->tabWidget->setTabEnabled(1,false); ui->tabWidget->setStyleSheet(“QTabBar::tab:disabled {width: 0; color: transparent;}”); 这种方法看似很秀,实际...
  • PYQT 实现TabWidget 双击关闭功能 soeasy
  • 主要介绍了Android程序开发之自定义设置TabHost,TabWidget样式的相关资料,需要的朋友可以参考下

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 1,576
精华内容 630
关键字:

tabwidget