OK... I am a bit lost... ( Maybe more that a bit )
I created the toolbar in QT Creator and added the actions to them.
Where can I get pointerToToolButton from the QAction?
Thanks again,
Louis
OK... I am a bit lost... ( Maybe more that a bit )
I created the toolbar in QT Creator and added the actions to them.
Where can I get pointerToToolButton from the QAction?
Thanks again,
Louis
Added after 1 39 minutes:
OK another step forward...
I can add a QPushButton to the toolbar and get the pressed() and released() signals as follows...
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QWidget>
#include <QWidgetAction>
#include <QPushButton>
#include <QToolButton>
#include <QDebug>
MainWindow
::MainWindow(QWidget *parent
) : ui(new Ui::MainWindow)
{
ui->setupUi(this);
ui->mainToolBar->addWidget(myPushButton);
connect(myPushButton,SIGNAL(pressed()),this,SLOT(ShowButtonPressed()));
connect(myPushButton,SIGNAL(released()),this,SLOT(ShowButtonReleased()));
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::ShowButtonPressed()
{
qDebug() << "Buttton Pressed";
}
void MainWindow::ShowButtonReleased()
{
qDebug() << "Buttton Released";
}
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QWidget>
#include <QWidgetAction>
#include <QPushButton>
#include <QToolButton>
#include <QDebug>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
QPushButton* myPushButton = new QPushButton("Hi");
ui->mainToolBar->addWidget(myPushButton);
connect(myPushButton,SIGNAL(pressed()),this,SLOT(ShowButtonPressed()));
connect(myPushButton,SIGNAL(released()),this,SLOT(ShowButtonReleased()));
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::ShowButtonPressed()
{
qDebug() << "Buttton Pressed";
}
void MainWindow::ShowButtonReleased()
{
qDebug() << "Buttton Released";
}
To copy to clipboard, switch view to plain text mode
What I am missing is the link between the QAction created in Qt Creator and its object so I can use the pressed() and released() signals.
At least I think that is what I am missing...
Again, thanks for your help and patience.
Louis
Bookmarks