孤单总是难免的

导航

 

 

/*
.pro/ .project 项目工程
QT += core gui 支持核心的界面编程
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++11
TARGET = asd 项目名字
TEMPLATE = app
DEFINES += QT_DEPRECATED_WARNINGS
RC_ICONS += login.ico 图标
SOURCES += \
main.cpp
HEADERS += \
logindialog.h \
FORMS += \
logindialog.ui
RESOURCES += \
image.qrc
*/
/*
QVariant h1(100);
h1.toInt();

 

h1.type();//保存的类型
h1.value<QColor>();//保存的值
h1.canConvert(QVariant::Int); 能不能转化
h1.convert(QVariant::Int); 转化
*/

 

/*
信号与曹
Q_OBJECT //支持信号与槽的宏

 

QMetaObject::Connection aa; //保存信号与槽连接的返回值
aa = connect(this,SIGNAL(xx(QString&)),
this,SLOT(ss(QString&)));
connect(this,&aa::xx,this,&aa::yyy);
connect(this,SIGNAL(xx(QString&)),this,SIGNAL(xxx()));

 

disconnect(aa);
disconnect(this,SIGNAL(xx(QString&)),this,SLOT(yyy(QString&)));
disconnect(this,SIGNAL(xx(QString&)),0,0);
disconnect(this,0,this,0);

 

signals:
void xx(QString& str); //信号不能也无需实现

 

private slots:
void on_yyy_clicked(){//自动连接,on_对象名_信号名
emit xx(str); //发送信号
};

 

*/

 

/*
动态属性系统

 

Q_PROPERTY(QString xx READ xx WRITE setxx NOTIFY xxChanged)
void setxx(QString strMaskNum){ 写
aa = strMaskNum;
emit xxChanged(strMaskNum);
};

 

QString xx()const{ 读
return aa;
};

signals:
void xxChanged(QString str); //信号

 

dd *aa = new dd;
QObject* obj = aa;
obj->property("xx").toString();//读
obj->setProperty("xx","kkkkkk");//写
*/
/*
qt 下载
http://download.qt.io/archive/qt/5.9/5.9.6/qt-opensource-windows-x86-5.9.6.exe

 

链接: https://pan.baidu.com/s/13GXBkqPFw5YcHew1blTTkw
提取码: emza
*/
//MinGW
//MSVC 2017

 

/*
QString h1;
h1.toInt(); //字符串转整数
h1.number(3.14); //小数转字符串
QString::number(30);整数转字符串
QByteArray tomArray = h1.toUtf8();
const char* aa = tomArray.data();

 

h1.append("xxx"); 尾部追加
h1.sprintf("%s%d%s","史前",400,"万年");字符串拼接
h1 = QString("%1%2").arg("史前").arg(400);字符串拼接
h1.at(2);//按照数组访问
h1.insert(5,h1.toUtf8()) 插入
h1.prepend("热带"); 头部插入
h1.replace(7,3,"三个月"); 替换
h1.startsWith("aaa");
h1.endsWith(".htm",Qt::CaseInsensitive)
h1.contains("A"); //是否包含"A"
h1.split(",");
QString::compare("Tom","tom",Qt::CaseInsensitive);//比较
h1.mid(5,3); 截取

 

QStringList h1;
插入:
h1 << "星期一" << "星期二" ;
h1.append("aaa");
h1.insert(0,"星期零");
访问:
h1.at(0);
h1.contains("xxx");
h1.size();
删除:
h1.removeFirst();
h1.removeLast();
h1.removeAt(0);
h1.removeOne("星期一");
h1.clear();
*/

 


/*
QList<int> h1;
//插入
h1 << 5 <<8;
h1.append(10);//尾部插入
h1.prepend(0);//头部插入
h1.insert(1,99);//指定位置插入
//访问
h1.at(2);
h1[2];
h1.contains(8);
h1.size();
//修改
h1.replace(5,66);
h1[0] = 100;
//删除
h1.removeFirst();
h1.removeLast();
h1.removeAt(2);
h1.removeOne(99);
h1.clear();
//QLinkedList类
QLinkedList<QString> h1;

 

QVector<int> h1; //向量
h1<<5<<6;
h1.append(1);
h1.prepend(2);
h1.replace(1,2);
h1.remove(0);
h1.removeAll(2);
h1[2];
h1.contains(3);

 

QMap<QString,QString> h1; //红黑树
//插入
h1.insert("aaa","100");
h1["bbb"] = "200";
//查找
h1["aaa"]; //通过key找value
h1.value("aaa");//通过key找value
h1.key("100");//value找key
h1.find("aaa");
QMultiMap<QString,QString> h2;
h2.insert("summer","15℃");
h2.insert("summer","35℃");
h2.remove("winter","-55℃");//独有
h2.values("winter");

QHash<int,QString> h1;
h1.insert(1,"一块钱");
h1[50] = "五十块钱";
h1.insertMulti(100,"毛爷爷"); //重复key 插入
*/

/*
QObject 所以qt对象的基类
ui:
objectName 设置类的名字
*/
/*
信號映射器
QSignalMapper h1
connect(button1, SIGNAL(triggered(bool)),
h1, SLOT(map()));
h1->setMapping(button1, 1);
connect(button2, SIGNAL(triggered(bool)),
h1, SLOT(map()));
h1->setMapping(button2, 2);

 

connect(h1, SIGNAL(mapped(int)),
this, SLOT(xxx(int)));
*/

 


/*
qobject_cast<ChildWnd*>(actWnd->widget()) 强制类型转换
*/

 

/*******************************************************/

 


/*
QTimer h1
h1.singleShot(0,qApp,SLOT(quit()));
h1.setInterval(1000); 设置间隔多少秒
h1.start(); 启动计时器
connect(h1,SIGNAL(timeout()),this,SLOT(bb()));

******************************************************
多少时间当前程序退出
设置间隔多少秒
启动计时器
间隔多少秒发出信号


*/

 


/*
QFile h1(文件路径)
h1.open(QIODevice::ReadOnly) 打开
h1.close(); 关闭
h1.readLine(buffer,sizeof(buffer)); 读一行
h1.setFileName("data.txt");设置文件的名字
h1.errorString(); 错误字符串
h1.exists() 文件是否存在
h1.readAll(); 读所有
************************************

 

打开
关闭
读一行
设置文件的名字
错误字符串
文件是否存在
读所有


*/

 

/*
QTextStream h2(&h1);
h2.setCodec("UTF-8"); 设置编码
h2.atEnd(); 是否读到文件尾
h2.readLine(); 读一行
************************************

 

设置编码
是否读到文件尾
读一行


*/

 

/*
QDataStream h3(&h1)
h3<< QString("易烊千玺") //写文件
h3 >> name ;//读文件

 


*/

 

/*
QFileInfo h1("路径");

 

h1.size(); //返回文件大小
h1.created(); //返回文件创建时间
h1.lastModified();//返回文件最后修改时间
h1.lastRead(); //文件最近阅读时间
h1.isDir(); //是否是目录
h1.isFile(); //是否是文件
h1.isSymLink(); //是否是系统链接
h1.isHidden(); //是否是隐藏文件
h1.isReadable(); //是否可读
h1.isWritable(); //是否可写
h1.isExecutable(); //是否可执行
h1.fileName();//返回文件名字
h1.canonicalFilePath();//返回标准的文件路径
*******************************

返回文件大小
返回文件创建时间
返回文件最后修改时间
文件最近阅读时间
是否是目录
是否是文件
是否是系统链接
是否是隐藏文件
是否可读
是否可写
是否可执行
返回文件名字
返回标准的文件路径

 


 

*/

 

/*
QTextDocumentWriter h1(docName);
h1.write(this->document());

*/

 


/*
QWidget h1 ->QObject

h1.resize(50, 50); //重置大小
h1.setFixedSize(50, 50); //设置固定大小
h1.setWindowTitle("xxxx");// 设置窗口标题
h1.setWindowFlags(Qt::Dialog );// 设置窗口标记
h1.setFont(QFont());// 设置字体
h1.setPalette(QPalette(QColor(209,215,255))); //设置调色板
h1.children();//返回子窗口的链表
h1.setWindowState(Qt::WindowMaximized);// 设置窗口状态
h1.move(50,90); //移动窗口
h1.setWindowModality(Qt::NonModal);
h1.setAutoFillBackground(true); //设置自动填充背景
h1.setLayout(mainLayout); //设置布局
void closeEvent(QCloseEvent *event) override;
event->accept(); //事件接受
event->ignore(); //事件忽略

 

**********************************

重置大小
设置固定大小
设置窗口标题
设置窗口标记
设置字体
设置调色板
返回子窗口的链表
设置窗口状态
移动窗口
设置窗口形式
设置自动填充背景
设置布局
事件接受
事件忽略

 


**********************************
ui
Enabled(true);
Geometry(0,0,100,100);
SizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred);
MinimumSize(0,0);
MaximumSize(200,200);
SizeIncrement(10,10);
BaseSize(10,10);
Cursor(QCursor());
MouseTracking(true);
TabletTracking(true);
FocusPolicy(Qt::NoFocus);
ContextMenuPolicy(Qt::DefaultContextMenu);
AcceptDrops(true);
WindowIcon(QIcon());
WindowOpacity(0.7);
ToolTip("aaa");
ToolTipDuration(10);
StatusTip("aaaa");
WhatsThis("asd");
AccessibleName("asdf");
AccessibleDescription("asdaa");
LayoutDirection(Qt::LeftToRight);
AutoFillBackground(true);
StyleSheet("xxx");
Locale(QLocale::Chinese);
WindowFilePath("xxxx");
InputMethodHints(Qt::ImhNone);
*/

 


/*
QDialog h1; ->QWidget

 

h1.exec(); 执行
QDialog::Accepted 接受
QDialog::Rejected 拒绝
done(Rejected);
done(Accepted);

 

**************************************

 

执行
接受
拒绝

 


ui
sizeGripEnabled; //大小把柄是否激活
modal //是否模态运行
*/

 


/*
QMainWindow h1 ->QWidget

 

h1.setCentralWidget(&h); 设置中心部件
h1.statusBar(); //返回状态条
h1.statusBar()->showMessage("文档已打开",3000);//状态条显示信息

 

***********************************

 

设置中心部件
返回状态条
状态条显示信息

 

ui:
centralwidget
iconSize
toolButtonStyle
animated
documentMode
tabShape
dockNestingEnabled
dockOptions
unifiedTitleandTool
*/

 


/*
QFrame h1 ->QWidget

 

h1.setFrameStyle(QFrame::Box); 设置框架风格

 

***************************************
设置框架风格

 

ui
frameshape
frameshadow
linewidth
midLineWidth
*/

 

/*
QLabel h1; ->QFrame->QWidget

 

h1.setScaledContents(true); 设置按比例填充内容
h1.setText("xxx"); 设置文本
h1.setWordWrap();设置单词换行
h1.setPixmap(QPixmap("tree.png")); 设置位图
h1.setBuddy();设置伙伴
*************************************

设置按比例填充内容
设置文本
设置单词换行
设置位图
设置伙伴

 

 

ui
textformat
alignment
margin
indent
openExternalLinks
textInteractionFlags

 

*/

 


/*
QRadioButton h1 QAbstractButton /
h1.setText("正确"); 设置文本
h1.setChecked(true); 设置选中
h1.text(); 返回文本
h1.isChecked();是否选中

 

***********************************
设置文本
设置选中
返回文本
是否选中

 


ui
icon
iconSize
shortcut
checkable
checked
autoRepeat
autoExclusive
autoRepeatDelay
autoRepeatInterval
*/

 

/*
QCheckBox h1; ->QWidget->QAbstractButton
h1.checkState();
*******************************
返回选择的状态

 

ui
tristate 是否设置三态

 

*/

 

/*
QPushButton h1; ->widget->QAbstractButton
connect(xx,SIGNAL(clicked(bool)),this,SLOT(ss()));

 

***********************************
点击信号

 

ui
autoDefault
default
flat
*/

 

/*
QButtonGroup h1 按钮分组 无界面

 

h1.add Button(QRadioButton& ); 添加按钮
h1.checkedButton(); 返回选择的按钮
********************************

 

添加按钮
返回选择的按钮

*/

 

 

 

/*
HorizontalLayout /verticalLayout
QHBoxLayout / QVBoxLayout h1

 

h1.setMargin(10); 设置边距
h1.setSpacing(10); 设置间隔
h1.addWidget(&w); 添加部件
h1.addItem(&s); 添加项目
h1.addLayout(&ha); 添加布局

 

*********************************

设置边距
设置间隔
添加部件
添加项目
添加布局

 

 

ui
layoutName 布局的名字
layoutLeftMargin 左边间距
layoutTopMargin 顶部间距
layoutRightMargin 右边间距
layoutBottomMargin 底部间距
layoutSpacing 控件之间的间隔
layoutStretch 控制布局伸展
layoutSizeConstraint 布局大小约束

 

*/

 


/*
QGridLayout h1;
h1.addWidget(&w,0,0,1,1); 添加部件
*********************************************

 

添加部件

 

ui
layoutName
layoutLeftMargin
layoutTopMargin
layoutRightMargin
layoutBottomMargin
layoutHorizontalSpacing
layoutVerticalSpacing
layoutRowStretch
layoutColumnStretch
layoutRowMinimumHeight(10,20);
layoutColumnMinimumWidth(10,20);
layoutSizeConstraint
*/

 

/*
QFormLayout h1;
h1.addRow(&w,&w);

 

*********************************************
添加行

 

ui
layoutName 布局的名字
layoutLeftMargin 左边间距
layoutTopMargin 顶部间距
layoutRightMargin 右边间距
layoutBottomMargin 底部间距
layoutHorizontalSpacing 布局水平方向的间隙
layoutVerticalSpacing 布局垂子方向的间隙

 

layoutFieldGrowthPolicy
layoutRowWrapPolicy
layoutLabelAlignment
layoutFormAlignment
layoutSizeConstraint 布局大小约束

 

*/

 

/*
Q Spacer Item h1(20,30) /horizontal Spacer / vertical spacer

 

*****************************
ui
spacerName
orientation
sizeType
sizeHint

 

*/

 

/*
文件对话框
QFileDialog h1;
h1.getOpenFileName(0, "标题", "..", " (*.cpp);;");
h1.getExisting Directory(0, "标题", ".");
h1.getSaveFileName(0,"标题",".");
*******************************************************

 

得到打开文件的路径(名字)
得到存在的目录的路径
得到保存文件的路径(名字)

*/

 

/*
颜色对话框
QColorDialog h1;
h1.getColor(Qt::yellow);
***********************************

 

得到颜色
*/
/*
字体对话框
QFontDialog h1;
h1.getFont(bool);
***********************************
得到字体
*/

 

/*
输入对话框
QInputDialog h1;
h1.getText(0,"标题","提示",QLineEdit::Normal,"aaa",&ok);
h1.getItem(0,"标题","提示:", sexList,0, true, &ok);
h1.getInt(0,"标题","提示:",20,0,120,1,&ok);
h1.getDouble(0, "标题", "提示:", 3.14, 0, 100,1, &ok);
****************************************
得到文本
得到字符串
得到整数
获取小数

 

*/

/*
QMessageBox h1;
h1.information (0,"标题","提示");
h1.question(0, "标题", "提示", QMessageBox::Cancel, QMessageBox::Ok );
h1.warning(0,"标题", "提示", QMessageBox::Save , QMessageBox::Cancel );
h1.critical(0, "标题","提示");
h1.about(0, "标题", "提示");

 

*********************************
信息消息框
问题消息框
错误消息框
危险消息框
关于消息框

 


自定义消息框
h1.setWindowTitle("自定义消息框");
h1.addButton("好吧", QMessageBox::ActionRole);
h1.addButton("算了吧",QMessageBox::Cancel);
h1.setIconPixmap(QPixmap("msg.png"));
h1.clickedButton();
h1.exec();
*************************************

添加按钮
设置图标位图
返回点击的按钮

 


*/

 


/*
QLineEdit h1; ->QWidget
h.setEchoMode(QLineEdit::Password); 设置反射模式
h.clear(); 清除
h.setFocus(); 设置焦点
h.text(); 返回文本
QLineEdit::returnPressed, 回车信号
h.displayText(); 返回显示文本
*************************

 

设置反射模式
清除
设置焦点
返回文本
回车信号
返回显示文本

 

ui
inputMask
text
maxLength
frame
cursorPosition
alignment
dragEnabled
readOnly
placeholderText
cursorMoveStyle
clearButtonEnabled
*/

 


/*
QAbstractScrollArea h1;
h1.setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
h1.setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
ui
设置垂直的滚动条策略
设置水平的滚动条策略

 

 

SizeAdjustPolicy(QAbstractScrollArea::AdjustIgnored);
*/

 


/*
QTextEdit h1 ->QAbstractScrollArea->QWidget
h1.setReadOnly(true); 设置只读
h1.setText("xxxx"); 设置文本
copyAvailable 复制信号可用
h1.textColor(); 返回文本颜色
h1.undo();取消
h1.redo();重做
h1.cut(); 剪切
h1.paste(); 粘贴
h1.copy(); 复制
h1.textCursor().hasSelection(); 文本光标有没有选择
QPrinter p;
h1.print(&p); 打印
********************************

设置只读
设置文本
复制信号可用
返回文本颜色
取消
重做
剪切
粘贴
复制
文本光标有没有选择
打印


ui
AutoFormatting(QTextEdit::AutoNone);
TabChangesFocus(true);
DocumentTitle("aaaa");
UndoRedoEnabled(true);
LineWrapMode(QTextEdit::WidgetWidth);
LineWrapColumnOrWidth(10);
Markdown("aaaa");
Html("aaaa");
OverwriteMode(true);
TabStopWidth(10);
TabStopDistance(41);
AcceptRichText(true);
CursorWidth(5);
TextInteractionFlags(Qt::TextSelectableByMouse);
PlaceholderText("adddd");
*/

 

/*
QPrinter h1(QPrinter::HighResolution);

 

***********************************
QPrintDialog h2(h1,this)
h2->setOption(QAbstractPrintDialog::PrintSelection,true);
h2->exec() == QDialog::Accepted

 

*****************************************

 

QPrintPreviewDialog h3(h1,this)
connect(&h3,SIGNAL(paintRequested(QPrinter*)),
this,SLOT(xxx(QPrinter*)));
h3.exec();
********************************
打印请求 信号

 

*/

 

/*
QMdiArea h1 ->QAbstractScrollArea->QFrame->QWidget
h1.addSubWindow(&w); 添加子窗口
h1.subWindowList(); 返回子窗口的链表
h1.setActiveSubWindow(m); 设置激活的子窗口
h1.activeSubWindow(); 返回激活的子窗口
h1.closeActiveSubWindow();关闭激活子窗口
h1.closeAllSubWindows(); 关闭所有的子窗口
h1.tileSubWindows(); 平铺子窗口
h1.cascadeSubWindows(); 串联子窗口
h1.activateNextSubWindow(); 激活下一个子窗口
h1.activatePreviousSubWindow();激活前一个子窗口
h1.currentSubWindow();返回当前子窗口
QMdiArea::subWindowActivated(QMidSubWindow), 子窗体激活 信号

 

***************************************************

 

添加子窗口
返回子窗口的链表
设置激活的子窗口
返回激活的子窗口
关闭激活子窗口
关闭所有的子窗口
平铺子窗口
串联子窗口
激活下一个子窗口
激活前一个子窗口
返回当前子窗口
子窗体激活 信号

 


ui
Background(QBrush());
ActivationOrder(QMdiArea::CreationOrder);
ViewMode(QMdiArea::SubWindowView);
DocumentMode(true);
TabsClosable(true);
TabsMovable(true);
TabShape(QTabWidget::Rounded);
TabPosition(QTabWidget::North);

 

*/

 


/*
QFont h1;

 

h1.setPointSize(12);
h1=QApplication::font();
h1.pointSize();
QFont::Bold
QFont::Normal
*************************

*/

/*
QFontDatabase h1;
h1.standardSizes() //返回标准字体大小的链表
*************************************************
返回标准字体大小的链表

 

*/
/*
QFontComboBox h1;

 

******************************
h1.setWritingSystem(QFontDatabase::Any);
h1.setFontFilters(QFontComboBox::AllFonts);
h1.setCurrentFont(QFont());

 

ui

 

WritingSystem(QFontDatabase::Any);
FontFilters(QFontComboBox::AllFonts);
CurrentFont(QFont());

 

*/

 


/*
QTextCharFormat h1;

 

h1.setFontWeight(QFont::Bold);
h1.setFontItalic(true);
h1.setFontUnderline(true);
h1.setFontFamily("宋体");
h1.setFontPointSize(3.6);
h1.setForeground(color);
******************************
*/

 

/*
QColor h1;
h1.isValid();
*/

 

/*
QPixmap pix(QSize(70,20));
pix.fill(QColor("黄色"));
*/

 

 

 

/*
QComboBox h1 ->QWidget 选择下拉框

 

h1.addItem(QString&); 添加项目
h1.findText(QString&); 返回当前字符串的索引
h1.setCurrentIndex(int);设置当前的索引

 


**********************************

 

 

 


h1.addItem(QIcon(pix), NULL);
h1.setIconSize(QSize(70,20));
h1.setSizeAdjustPolicy(QComboBox::AdjustToContents);

 

ui
Editable(true);
CurrentText("sss");
CurrentIndex(10);
MaxVisibleItems(10);
MaxCount(210);
InsertPolicy(QComboBox::InsertAtBottom);
SizeAdjustPolicy(QComboBox::AdjustToContents);
MinimumContentsLength(0);
IconSize(QSize(16,16));
DuplicatesEnabled(true);
frame(true)
ModelColumn(0);
*/

 

 

 

/*
QMenu h1;
QMenu::aboutToShow 信号

 

**************************

 

h1.addAction("ddddd");
h1.addAction(QAction*);
h1.addSeparator();
h1.clear();
h1.setTitle("aaa");
h1.addMenu("cccc");

 

ui
TearOffEnabled(true);
Title("aaa");
Icon(QIcon());
SeparatorsCollapsible(true);
ToolTipsVisible(true);
*/

 

 

 


/*
QAction h1; ->QObject
h1.isChecked()
h1.setIcon(QPixmap);
h1.setCheckable(true);
h1.setChecked(true);

 

***************************

 

h1.setText("一样");
h1.setIconText("一样");
QIcon i("../bold.png");

 

h1.setToolTip("aaa");
h1.setStatusTip("asssss");

 

h1.setFont(f);
h1.setShortcut(QKeySequence("Ctrl+k"));

 


SIGNAL(triggered(bool) 信号

 

h1.setWhatsThis("asas");
h1.setShortcutContext(Qt::WidgetShortcut);
h1.setAutoRepeat(true);
h1.setVisible(true);
h1.setMenuRole(QAction::NoRole);
h1.setIconVisibleInMenu(true);
h1.setShortcutVisibleInContextMenu(true);
h1.setPriority(QAction::LowPriority);

 

ui

 

Checkable(true);
Checked(true);
Enabled(true);
Icon(I);
Text("一样");
IconText("一样");
toolTip("aaa");
statusTip("cc");
WhatsThis("asas");
Font();
Shortcut(QKeySequence::Open);
ShortcutContext(Qt::WidgetShortcut);
AutoRepeat(true);
Visible(true);
MenuRole(QAction::NoRole);
IconVisibleInMenu(true);
ShortcutVisibleInContextMenu(true);
Priority(QAction::LowPriority);

 

*/

 

/*
QActionGroup h1;
h1.addAction(QAction & );

 

*/

 

 

 



 

 

 

/*
QMenuBar ->QWidget

 

h->addMenu(QMenu*); 添加菜单
h.addAction(QAction* );添加按钮

 


ui
defaultUp
nativeMenuBar

 

*/

 

 

 

/*
QToolBar h1;
h1.addAction(QWidget*);

 

***************************
h1.setMovable(true);
h1.setAllowedAreas(Qt::LeftToolBarArea);
h1.setOrientation(Qt::Horizontal);
h1.setIconSize(QSize(24,24));
h1.setToolButtonStyle(Qt::ToolButtonIconOnly);
h1.setFloatable(true);

 

ui
Movable(true);
AllowedAreas(Qt::LeftToolBarArea);
Orientation(Qt::Horizontal);
IconSize(QSize(24,24));
ToolButtonStyle(Qt::ToolButtonIconOnly);
Floatable(true);

 

*/

 


/*
Qt::mightBeRichText(text)
/*

 


 

posted on 2022-10-19 23:16  孤单总是难免的  阅读(300)  评论(0)    收藏  举报