本文整理汇总了C++中QToolButton::setFixedWidth方法的典型用法代码示例。如果您正苦于以下问题:C++ QToolButton::setFixedWidth方法的具体用法?C++ QToolButton::setFixedWidth怎么用?C++ QToolButton::setFixedWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QToolButton
的用法示例。
在下文中一共展示了QToolButton::setFixedWidth方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QWidget
ObjectReferenceEdit::ObjectReferenceEdit(QWidget *parent)
: QWidget(parent),
mErrorTextColor(Qt::red)
{
QHBoxLayout *layout = new QHBoxLayout(this);
layout->setMargin(0);
layout->setSpacing(0);
mLineEdit = new QLineEdit(this);
mLineEdit->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred));
mOkTextColor = mLineEdit->palette().color(QPalette::Active, QPalette::Text);
QToolButton *button = new QToolButton(this);
button->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred));
button->setFixedWidth(20);
button->setText(QLatin1String("..."));
layout->addWidget(mLineEdit);
layout->addWidget(button);
connect(button, SIGNAL(clicked(bool)),
SLOT(buttonClicked()));
connect(mLineEdit, SIGNAL(textChanged(QString)),
SLOT(validate()));
connect(mLineEdit, SIGNAL(textEdited(QString)),
SLOT(setObjectId(QString)));
setFocusProxy(mLineEdit);
setFocusPolicy(Qt::StrongFocus);
setAttribute(Qt::WA_InputMethodEnabled);
}
示例2: QWidget
FileEdit::FileEdit(QWidget *parent)
: QWidget(parent)
, mErrorTextColor(Qt::red)
{
QHBoxLayout *layout = new QHBoxLayout(this);
layout->setMargin(0);
layout->setSpacing(0);
mLineEdit = new QLineEdit(this);
mLineEdit->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred));
mOkTextColor = mLineEdit->palette().color(QPalette::Active, QPalette::Text);
QToolButton *button = new QToolButton(this);
button->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred));
button->setFixedWidth(20);
button->setText(QLatin1String("..."));
layout->addWidget(mLineEdit);
layout->addWidget(button);
setFocusProxy(mLineEdit);
setFocusPolicy(Qt::StrongFocus);
setAttribute(Qt::WA_InputMethodEnabled);
connect(mLineEdit, &QLineEdit::textEdited,
this, &FileEdit::textEdited);
connect(mLineEdit, &QLineEdit::textChanged,
this, &FileEdit::validate);
connect(button, &QAbstractButton::clicked,
this, &FileEdit::buttonClicked);
}
示例3: createButton
QToolButton* MenyBar::createButton(QString title) {
QToolButton *genericButton = new QToolButton(this);
genericButton->setText(title);
genericButton->setFixedHeight(50);
genericButton->setFixedWidth(100);
return genericButton;
}
示例4: assignColorFromSMVTreeWidget
void FeatureTreeWidget::assignColorFromSMVTreeWidget(QString featureName)
{
QTreeWidgetItem *item = getItemFromFeatureName(featureName);
if (item!=0)
{
if (item->childCount()==0){
mainWindow->questionDialog->writeToLog("assignColor<1>");
Feature *f = getCorrespondingFeature(featureName);
Color *c = static_cast<MyListWidgetItem*>(listWidget->selectedItems().at(0))->getBGColor();
if (item->backgroundColor(0).isValid())
mainWindow->removeColorAssignment(static_cast<MyTreeWidgetItem*>(item));
colorManager->setColorForFeature(f,c);
//X zum Abwählen der Farbe setzen
if (itemWidget(item, 1))
itemWidget(item, 1)->show();
else{
QToolButton *deleteButton = new QToolButton(this);
deleteButton->setFont(QFont(QString("MS Shell Dlg 2"),9,10,false));
//deleteButton->setFixedSize(15,18);
deleteButton->setFixedWidth(16);
QIcon icon = QIcon();
icon.addPixmap(QPixmap(QString(":/images/cross.png")),QIcon::Normal,QIcon::On);
deleteButton->setIcon(icon);
deleteButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
setItemWidget(item,1,deleteButton);
connect(deleteButton,SIGNAL(clicked()),this,SLOT(removeColorAssignment()));
}
//aktualisiere SmvTreeWidget und TextEdit
mainWindow->updateSMVTreeTexture(f);
redrawListWidget();
//wenn Farbe schon in FeatureTreeWidget vorhanden, setze diese auf weiß/transparent
QList <QTreeWidgetItem*> *treeList = new QList <QTreeWidgetItem*>();
findBackGroundColor(c->color,root,treeList);
if (treeList->isEmpty()==false)
{
for (int i = 0;i < treeList->size();i++){
static_cast<MyTreeWidgetItem*>(treeList->at(i))->setBackgroundInvalid();
// treeList->at(i)->background(0).setStyle(Qt::NoBrush);
// treeList->at(i)->setBackgroundColor(0,QColor(0,0,0,0));
colorManager->deleteColorForFeature(getCorrespondingFeature(treeList->at(i)->text(0)));
}
}
//setze Farbe im FeatureTreeWidget
static_cast<MyTreeWidgetItem*>(item)->setBGColor(c);
//item->setBackgroundColor(0,selected->color);
}
}
}
示例5: fillControlToolBar
//!
//! Fills the panel's control and options tool bars with the given actions.
//!
//! \param controlActions The actions to add to the control tool bar.
//! \param optionsActions The actions to add to the options tool bar.
//!
void TimelinePanel::fillControlToolBar ( QList<QAction *> controlActions )
{
m_controlToolBar->addActions(controlActions);
// set the popup mode for all tool buttons in the control tool bar to immediately display an associated menu (if present)
for (int i = 0; i < controlActions.size(); ++i) {
QToolButton *toolButton = qobject_cast<QToolButton *>(m_controlToolBar->widgetForAction(controlActions[i]));
if (toolButton) {
toolButton->setPopupMode(QToolButton::InstantPopup);
toolButton->setFixedWidth(44);
}
}
}
示例6: QWidget
KexiDBDateTimeEdit::KexiDBDateTimeEdit(const QDateTime &datetime, QWidget *parent)
: QWidget(parent), KexiFormDataItemInterface()
{
m_invalidState = false;
m_cleared = false;
m_readOnly = false;
m_dateEdit = new Q3DateEdit(datetime.date(), this);
m_dateEdit->setAutoAdvance(true);
m_dateEdit->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::MinimumExpanding);
// m_dateEdit->setFixedWidth( QFontMetrics(m_dateEdit->font()).width("8888-88-88___") );
connect(m_dateEdit, SIGNAL(valueChanged(QDate)), this, SLOT(slotValueChanged()));
connect(m_dateEdit, SIGNAL(valueChanged(QDate)), this, SIGNAL(dateTimeChanged()));
QToolButton* btn = new QToolButton(this);
btn->setText("...");
btn->setFixedWidth(QFontMetrics(btn->font()).width(" ... "));
btn->setPopupDelay(1); //1 ms
m_timeEdit = new Q3TimeEdit(datetime.time(), this);
m_timeEdit->setAutoAdvance(true);
m_timeEdit->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::MinimumExpanding);
connect(m_timeEdit, SIGNAL(valueChanged(QTime)), this, SLOT(slotValueChanged()));
connect(m_timeEdit, SIGNAL(valueChanged(QTime)), this, SIGNAL(dateTimeChanged()));
#ifdef QDateTimeEditor_HACK
m_dte_date = KexiUtils::findFirstChild<QDateTimeEditor>(m_dateEdit, "QDateTimeEditor");
m_dte_time = KexiUtils::findFirstChild<QDateTimeEditor>(m_timeEdit, "QDateTimeEditor");
#else
m_dte_date = 0;
#endif
m_datePickerPopupMenu = new QMenu(0, "date_popup");
connect(m_datePickerPopupMenu, SIGNAL(aboutToShow()), this, SLOT(slotShowDatePicker()));
m_datePicker = new KDatePicker(m_datePickerPopupMenu, QDate::currentDate(), 0);
KDateTable *dt = KexiUtils::findFirstChild<KDateTable>(m_datePicker, "KDateTable");
if (dt)
connect(dt, SIGNAL(tableClicked()), this, SLOT(acceptDate()));
m_datePicker->setCloseButton(true);
m_datePicker->installEventFilter(this);
m_datePickerPopupMenu->insertItem(m_datePicker);
btn->setPopup(m_datePickerPopupMenu);
QHBoxLayout* layout = new QHBoxLayout(this);
layout->addWidget(m_dateEdit, 0);
layout->addWidget(btn, 0);
layout->addWidget(m_timeEdit, 0);
//layout->addStretch(1);
setFocusProxy(m_dateEdit);
}
示例7: QWidget
Timer::Timer(QWidget *parent) :
QWidget(parent)
{
setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum);
timerSettingFrame = new QFrame;
timerRunningFrame = new QFrame;
hourEdit = new QSpinBox;
minEdit = new QSpinBox;
secEdit = new QSpinBox;
timeLabel = new QLabel;
QToolButton *startButton = new QToolButton(this);
startButton->setText(tr("Start")),
connect(startButton, SIGNAL(released()), this, SLOT(startTime()));
QToolButton *resetButton = new QToolButton(this);
resetButton->setText(tr("Reset"));
connect(resetButton, SIGNAL(pressed()), this, SLOT(resetTime()));
QToolButton *pauseButton = new QToolButton(this);
pauseButton->setText(tr("Pause"));
pauseButton->setCheckable(true);
connect(pauseButton, SIGNAL(clicked(bool)), this, SLOT(pauseTime(bool)));
resetButton->setFixedWidth(50);
startButton->setFixedWidth(50);
pauseButton->setFixedWidth(50);
hourEdit->setFixedWidth(50);
hourEdit->setRange(0,24);
hourEdit->setAccelerated(true);
hourEdit->setSuffix(tr(" h"));
minEdit->setFixedWidth(50);
minEdit->setRange(0,60);
minEdit->setAccelerated(true);
minEdit->setSuffix(tr(" min"));
secEdit->setFixedWidth(50);
secEdit->setRange(0,60);
secEdit->setAccelerated(true);
secEdit->setSuffix(tr(" s"));
secEdit->hide();
connect(minEdit,SIGNAL(valueChanged(int)),this,SLOT(minSpinFormat(int)));
connect(secEdit,SIGNAL(valueChanged(int)),this,SLOT(secSpinFormat(int)));
timeLabel->setMinimumWidth(50);
QGridLayout *settingLayout = new QGridLayout;
settingLayout->addWidget(hourEdit,0,0);
settingLayout->addWidget(minEdit,0,1);
settingLayout->addWidget(secEdit,0,2);
settingLayout->addWidget(startButton,1,0,1,3,Qt::AlignHCenter);
settingLayout->setSpacing(2);
settingLayout->setContentsMargins(3,3,3,3);
timerSettingFrame->setLayout(settingLayout);
QGridLayout *runningLayout = new QGridLayout;
runningLayout->addWidget(timeLabel,0,0,1,2,Qt::AlignHCenter);
runningLayout->addWidget(resetButton,1,0);
runningLayout->addWidget(pauseButton,1,1);
runningLayout->setSpacing(2);
runningLayout->setContentsMargins(3,3,3,3);
timerRunningFrame->setLayout(runningLayout);
QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(timerSettingFrame);
layout->addWidget(timerRunningFrame);
layout->setContentsMargins(3,3,3,3);
setLayout(layout);
timerRunningFrame->hide();
timerSettingFrame->show();
}
示例8: QWidget
//The main constructor.
GofunWidget::GofunWidget(WFlags f) : QWidget(0,0,f)
{
//Set up some accelerators
accel = new QAccel(this);
//Do some layout magic
QHBoxLayout* hbox = new QHBoxLayout(this);
QVBoxLayout* vbox = new QVBoxLayout();
QHBoxLayout* hboxr = new QHBoxLayout();
QHBoxLayout* hboxlabel = new QHBoxLayout();
//This button group contains the buttons for the different directories
cats_bg = new GofunVButtonGroup(this);
cats_bg->setExclusive(true);
cats_bg->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Expanding,false);
connect(cats_bg, SIGNAL(clicked(int)),this, SLOT(changeDirectory(int)));
//We 'load' this WidgetStack with GofunIconViews later on
view_ws = new QWidgetStack(this);
view_ws->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding,false);
//It should be obvious what that is being
QPushButton* quit = new QPushButton(tr("Quit"), this, "quit");
quit->setFont(QFont("Times", 18));
quit->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum,false);
connect(quit, SIGNAL(clicked()), qApp, SLOT(quit()));
//The button marking your way to the settings-dialog
QToolButton* config = new QToolButton(this);
config->setPixmap(QPixmap("config.png"));
QToolTip::add(config,tr("Settings"));
connect(config, SIGNAL(clicked()),this, SLOT(openSettingsDlg()));
//A helpful help-button
QToolButton* help = new QToolButton(this);
help->setPixmap(QPixmap("help.png"));
QToolTip::add(help,tr("Help"));
connect(help, SIGNAL(clicked()),this, SLOT(showHelp()));
//Layout magic, basically we add the WidgetStack and a vertical box to the
//top horizontal box
hbox->addWidget(view_ws);
hbox->addLayout(vbox);
//Isn't it nice?
QLabel* gflabel = new QLabel("GoFun",this);
gflabel->setFont(QFont("Times",18, QFont::Bold));
gflabel->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum,0);
vbox->addLayout(hboxlabel);
hboxlabel->addWidget(gflabel);
//Common it is ...
QToolButton* gficon = new QToolButton(this);
gficon->setFixedWidth(32);
gficon->setPixmap(QPixmap("gofun.png"));
QToolTip::add(gficon,tr("About"));
hboxlabel->addWidget(gficon);
connect(gficon,SIGNAL(clicked()),this,SLOT(showAbout()));
//The last steps in our layout magic
vbox->addWidget(cats_bg);
tools_cat = new GofunDirectoryButton("GoTools",this);
vbox->addWidget(tools_cat);
QWidget* wid = new QWidget(this);
wid->setMinimumHeight(5);
vbox->addWidget(wid);
vbox->addLayout(hboxr);
hboxr->addWidget(quit);
hboxr->addWidget(config);
hboxr->addWidget(help);
//This toolbutton shall be used to add directories
QToolButton* cat_add = new QToolButton(Qt::DownArrow,cats_bg);
connect(cat_add, SIGNAL(clicked()),this, SLOT(popupDirectoryAdd()));
QToolTip::add(cat_add,tr("Click this button to operate on directories"));
cats_bg->insert(cat_add);
//Now load the whole GoFun-Data and care for its displaying
loadData();
}
示例9: dropEvent
void FeatureTreeWidget::dropEvent(QDropEvent *event)
{
//Darstellen des Drag-Bildes
QByteArray itemData = event->mimeData()->data("application/x-dnditemdata");
QDataStream dataStream(&itemData, QIODevice::ReadOnly);
QPixmap pixmap;
QPoint offset;
dataStream >> pixmap >> offset;
QTreeWidgetItem *item = itemAt(event->pos().x(),event->pos().y());
//wenn auf ein TreeWidgetItem gedropt und dieses ein Blattknoten ist
if (item!=0)
{
if (item->childCount()==0){
mainWindow->questionDialog->writeToLog("assignColor<1>");
Feature *f = getCorrespondingFeature(item->text(0));
//Color *c = new Color (selected->color.convertTo(QColor::Hsv));
Color *c = static_cast<MyListWidgetItem*>(listWidget->selectedItems().at(0))->getBGColor();
if (item->backgroundColor(0).isValid())
mainWindow->removeColorAssignment(static_cast<MyTreeWidgetItem*>(item));
colorManager->setColorForFeature(f,c);
//X zum Abwählen der Farbe setzen
if (itemWidget(item, 1))
itemWidget(item, 1)->show();
else{
QToolButton *deleteButton = new QToolButton(this);
deleteButton->setFont(QFont(QString("MS Shell Dlg 2"),9,10,false));
//deleteButton->setFixedSize(15,18);
deleteButton->setFixedWidth(16);
QIcon icon = QIcon();
icon.addPixmap(QPixmap(QString(":/images/cross.png")),QIcon::Normal,QIcon::On);
deleteButton->setIcon(icon);
deleteButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
setItemWidget(item,1,deleteButton);
connect(deleteButton,SIGNAL(clicked()),this,SLOT(removeColorAssignment()));
}
//aktualisiere SmvTreeWidget und TextEdit
mainWindow->updateSMVTreeTexture(f);
redrawListWidget();
//wenn Farbe schon in FeatureTreeWidget vorhanden, setze diese auf weiß/transparent
QList <QTreeWidgetItem*> *treeList = new QList <QTreeWidgetItem*>();
findBackGroundColor(c->color,root,treeList);
if (treeList->isEmpty()==false)
{
for (int i = 0;i < treeList->size();i++){
static_cast<MyTreeWidgetItem*>(treeList->at(i))->setBackgroundInvalid();
// treeList->at(i)->background(0).setStyle(Qt::NoBrush);
// treeList->at(i)->setBackgroundColor(0,QColor(0,0,0,0));
colorManager->deleteColorForFeature(getCorrespondingFeature(treeList->at(i)->text(0)));
}
}
//setze Farbe im FeatureTreeWidget
static_cast<MyTreeWidgetItem*>(item)->setBGColor(c);
//item->setBackgroundColor(0,selected->color);
}
event->ignore();
}
}
示例10: assignAutomatically
void FeatureTreeWidget::assignAutomatically(){
QString size = "";
size = size.setNum(selectedItems().size());
mainWindow->questionDialog->writeToLog("assignColor<" + size + ">");
//schon zugewiesene Farben löschen
for (int i = 0; i < selectedItems().size();i++){
MyTreeWidgetItem *item = static_cast<MyTreeWidgetItem*>(selectedItems().at(i));
if (item->backgroundColor(0).isValid()){
MyListWidgetItem *listItem = new MyListWidgetItem(QString(""));
listItem->setBGColor(item->getBGColor());
//Icon wichtig, damit Item überhaupt angezeigt wird!
QIcon icon = QIcon();
icon.addPixmap(QPixmap(QString(":/images/leer.png")),QIcon::Normal,QIcon::On);
listItem->setIcon(icon);
listWidget->addItem(listItem);
colorManager->deleteColorForFeature(getCorrespondingFeature(item->text(0)));
//item->setBackgroundColor(0,QColor(-1,-1,-1,-1));
item->setBackgroundInvalid();
itemWidget(item,1)->hide();
}
}
int cnt = 0;
if (selectedItems().size() <= listWidget->count())
cnt = selectedItems().size();
else
cnt = listWidget->count();
//nacheinander jedem ausgewählten Knoten, möglichst unterschiedliche Farben des ListWidgets zuweisen
QList <Color*> *colors = new QList<Color*>();
int step = 0;
if (cnt >1) //Division durch 0 verhindern
step = (listWidget->count()-1)/(cnt-1);
else
step = 0;
//Farben unterschiedlicher wählen
if (step < selectedItems().size()/15)
step = selectedItems().size()/15;
//Farbliste füllen
if (cnt > 1){
for (int i = 0;i < cnt;i++){
int add = 0;
while (colors->contains(static_cast<MyListWidgetItem*>(listWidget->item((i*step + add)%listWidget->count()))->getBGColor())){
add++;
}
colors->push_back(static_cast<MyListWidgetItem*>(listWidget->item((i*step + add)%listWidget->count()))->getBGColor());
}
}else{
int random = rand() % listWidget->count();
colors->push_back(static_cast<MyListWidgetItem*>(listWidget->item(random))->getBGColor());
}
for (int i = 0; i < cnt;i++){
QTreeWidgetItem *item = selectedItems().at(i);
Feature *f = getCorrespondingFeature(item->text(0));
//Color *c = static_cast<MyListWidgetItem*>(listWidget->item(0))->getBGColor();
Color *c = colors->at(i);
colorManager->setColorForFeature(f,c);
//aktualisiere SmvTreeWidget und TextEdit
mainWindow->updateSMVTreeTexture(f);
//X zum Abwählen der Farbe setzen
if (itemWidget(item, 1))
itemWidget(item, 1)->show();
else{
QToolButton *deleteButton = new QToolButton(this);
deleteButton->setFont(QFont(QString("MS Shell Dlg 2"),9,10,false));
//deleteButton->setFixedSize(15,18);
deleteButton->setFixedWidth(16);
QIcon icon = QIcon();
icon.addPixmap(QPixmap(QString(":/images/cross.png")),QIcon::Normal,QIcon::On);
deleteButton->setIcon(icon);
deleteButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
setItemWidget(item,1,deleteButton);
connect(deleteButton,SIGNAL(clicked()),this,SLOT(removeColorAssignment()));
}
//wenn Farbe schon in FeatureTreeWidget vorhanden, setze diese auf weiß/transparent
QList <QTreeWidgetItem*> *treeList = new QList <QTreeWidgetItem*>();
findBackGroundColor(listWidget->item(0)->backgroundColor(),root,treeList);
if (treeList->isEmpty()==false)
{
for (int i = 0;i < treeList->size();i++){
static_cast<MyTreeWidgetItem*>(treeList->at(i))->setBackgroundInvalid();
// treeList->at(i)->background(0).setStyle(Qt::NoBrush);
// treeList->at(i)->setBackgroundColor(0,QColor(0,0,0,0));
colorManager->deleteColorForFeature(getCorrespondingFeature(treeList->at(i)->text(0)));
}
}
//setze Farbe im FeatureTreeWidget
static_cast<MyTreeWidgetItem*>(item)->setBGColor(c);
//.........这里部分代码省略.........